private void ShowNotification(HttpMethod method, HttpStatusCode responseStatus) { if (responseStatus == HttpStatusCode.OK) { string message = null; if (method == HttpMethod.Post) { message = "Successfully added"; } else if (method == HttpMethod.Put) { message = "Successfully updated"; } else if (method == HttpMethod.Delete) { message = "Successfully deleted"; } else { return; } _notification.Success(message); } else if (responseStatus == HttpStatusCode.Forbidden) { _notification.Warning("You don't have permission to do that"); } else { string message = null; if (method == HttpMethod.Get) { message = "Failed to fetch data"; } if (method == HttpMethod.Post) { message = "Failed to add data"; } else if (method == HttpMethod.Put) { message = "Failed to update data"; } else if (method == HttpMethod.Delete) { message = "Failed to delete data"; } else { return; } _notification.Error(message); } }
public async Task <List <UserForListViewDto> > GetUsers(GetUserQueryParams queryParams) { var properties = from p in queryParams.GetType().GetProperties() where p.GetValue(queryParams, null) != null select p.Name + "=" + HttpUtility.UrlEncode(p.GetValue(queryParams, null).ToString()); string queryString = String.Join("&", properties.ToArray()); var users = await _apiService.GetFromJsonAsync <UserListResponseDto>( $"accounts/api/admin/users?{queryString}"); if (!users.Data.Any()) { _notification.Warning("No matching users"); } return(users.Data); }