Use string Interpolation for constructing Urls (#324)

This commit is contained in:
Hisham Bin Ateya
2020-04-03 19:44:54 +03:00
committed by GitHub
parent 2433cc06be
commit 7786cd027b
22 changed files with 124 additions and 108 deletions

View File

@ -28,14 +28,14 @@ namespace Oqtane.Services
public async Task<List<Notification>> GetNotificationsAsync(int siteId, string direction, int userId)
{
string querystring = "?siteid=" + siteId.ToString() + "&direction=" + direction.ToLower() + "&userid=" + userId.ToString();
List<Notification> notifications = await _http.GetJsonAsync<List<Notification>>(Apiurl + querystring);
var notifications = await _http.GetJsonAsync<List<Notification>>($"{Apiurl}? siteid={siteId.ToString()}&direction={direction.ToLower()}&userid={userId.ToString()}");
return notifications.OrderByDescending(item => item.CreatedOn).ToList();
}
public async Task<Notification> GetNotificationAsync(int notificationId)
{
return await _http.GetJsonAsync<Notification>(Apiurl + "/" + notificationId.ToString());
return await _http.GetJsonAsync<Notification>($"{Apiurl}/{notificationId.ToString()}");
}
public async Task<Notification> AddNotificationAsync(Notification notification)
@ -45,11 +45,11 @@ namespace Oqtane.Services
public async Task<Notification> UpdateNotificationAsync(Notification notification)
{
return await _http.PutJsonAsync<Notification>(Apiurl + "/" + notification.NotificationId.ToString(), notification);
return await _http.PutJsonAsync<Notification>($"{Apiurl}/{notification.NotificationId.ToString()}", notification);
}
public async Task DeleteNotificationAsync(int notificationId)
{
await _http.DeleteAsync(Apiurl + "/" + notificationId.ToString());
await _http.DeleteAsync($"{Apiurl}/{notificationId.ToString()}");
}
}
}