private async Task OnValidSubmit() { try { this.IsLoading = true; var response = await AuthorizedHttpClient.PostAsJsonAsync("api/Promotion/AddPromotion", this.PromotionModel); if (!response.IsSuccessStatusCode) { var problemHttpResponse = await response.Content.ReadFromJsonAsync <ProblemHttpResponse>(); await this.ToastifyService.DisplayErrorNotification(problemHttpResponse.Detail); } else { await this.ToastifyService.DisplaySuccessNotification("Promotion has been added"); NavigationManager.NavigateTo("Admin/Promos/List"); } } catch (Exception ex) { await ToastifyService.DisplayErrorNotification(ex.Message); } finally { this.IsLoading = false; } }
public async Task <int> SecureGetCountAsync(NodeSearch nodeSearch) { var request = $"{API_URL}/GetCount"; var response = await AuthorizedHttpClient.PostAsJsonAsync <NodeSearch>(request, nodeSearch); var count = await response.Content.ReadAsStringAsync(); return(int.Parse(count)); }
public async Task <HttpResponseMessage> AddAsync(Category category) { var response = await AuthorizedHttpClient.PostAsJsonAsync <Category>(API_URL, category); var id = await response.Content.ReadAsStringAsync(); category.Id = id; return(response); }
public async Task <HttpResponseMessage> PostAsync(Group group) { var response = await AuthorizedHttpClient.PostAsJsonAsync <Group>(API_URL, group); var id = await response.Content.ReadAsStringAsync(); group.Id = id; return(response); }
public async Task <HttpResponseMessage> AddAsync(ContentActivity contentActivity) { var response = await AuthorizedHttpClient.PostAsJsonAsync <ContentActivity>(API_URL, contentActivity); var id = await response.Content.ReadAsStringAsync(); contentActivity.Node.Id = id; return(response); }
public async Task <Node[]> SecureGetAsync( NodeSearch nodeSearch, int currentPage) { var request = $"{API_URL}/GetPaginatedResult?currentPage={currentPage}"; var response = await AuthorizedHttpClient.PostAsJsonAsync <NodeSearch>(request, nodeSearch); var jsonString = await response.Content.ReadAsStringAsync(); return(System.Text.Json.JsonSerializer.Deserialize <Node[]>(jsonString, _jsonSerializerOptions)); }
public async Task <int> AddAsync(string id, bool isUpVote) { var voteAction = new VoteAction() { ItemId = id, IsUpVote = isUpVote }; var response = await AuthorizedHttpClient.PostAsJsonAsync(API_URL, voteAction); var votes = await response.Content.ReadAsStringAsync(); int output = 0; int.TryParse(votes, out output); return(output); }
public async Task <Node> SecureGetAsync( string module, string type, string slug) { var nodeSearch = new NodeSearch() { Module = module, Type = type, Slug = slug }; var request = $"{API_URL}/GetPaginatedResult"; var response = await AuthorizedHttpClient.PostAsJsonAsync <NodeSearch>(request, nodeSearch); var jsonString = await response.Content.ReadAsStringAsync(); var items = System.Text.Json.JsonSerializer.Deserialize <Node[]>(jsonString, _jsonSerializerOptions); return(items.FirstOrDefault()); }
public async Task <HttpResponseMessage> Invite(Invitation invitation) { return(await AuthorizedHttpClient.PostAsJsonAsync <Invitation>(API_URL, invitation)); }