public async Task <CategoryModel> UpdateCategory(CategoryModel category) { try { IEModel <CategoryModel> response = await httpClient.PutJsonAsync <IEModel <CategoryModel> >("api/category", category); if (response.ErrorStatusCode != CustomErrorCode.Sucess) { throw new Exception(response.CustomMessage); } return(response.Payload); } catch (HttpRequestException ex) { throw ex; } }
public async Task <DocumentModel> UpdateDocument(DocumentModel document) { try { IEModel <DocumentModel> response = await httpClient.PutJsonAsync <IEModel <DocumentModel> >("api/document", document); if (response.ErrorStatusCode != CustomErrorCode.Sucess) { throw new Exception(response.CustomMessage); } return(response.Payload); } catch (HttpRequestException ex) { throw ex; } }
public async Task <IEnumerable <CategoryModel> > GetCategoryList() { try { IEModel <IEnumerable <CategoryModel> > response = await httpClient.GetJsonAsync <IEModel <IEnumerable <CategoryModel> > >("api/category"); if (response.ErrorStatusCode != CustomErrorCode.Sucess) { throw new Exception(response.CustomMessage); } return(response.Payload); } catch (HttpRequestException ex) { throw ex; } }
public async Task <CategoryModel> DeleteCategory(int ID) { try { HttpResponseMessage httpResponse = await httpClient.DeleteAsync("api/category/" + ID); IEModel <CategoryModel> response = JsonConvert.DeserializeObject <IEModel <CategoryModel> >(await httpResponse.Content.ReadAsStringAsync()); if (response.ErrorStatusCode != CustomErrorCode.Sucess) { throw new Exception(response.CustomMessage); } return(response.Payload); } catch (HttpRequestException ex) { throw ex; } }
public async Task <DocumentModel> Download(DocumentModel document) { try { IEModel <DocumentModel> response = await httpClient.GetJsonAsync <IEModel <DocumentModel> >($"api/document/download/{document.ID}"); if (response.ErrorStatusCode != CustomErrorCode.Sucess) { throw new Exception(response.CustomMessage); } DocumentModel content = response.Payload; await JS.SaveAs(content.FILE_NAME, content.FILE.FILE); return(content); } catch (HttpRequestException ex) { throw ex; } }