public async Task<ResponseBool> SupplierMappingSaveAsync(CostCentreMapping mapping) { ResponseBool _response = new ResponseBool { Success = false, ErrorInfo = "" }; string url = string.Format("api/distributorservices/commoditysuppliermapping"); var httpClient = setupHttpClient(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); try { var response = await httpClient.PostAsJsonAsync(url, mapping); _response = await response.Content.ReadAsAsync<ResponseBool>(); } catch (Exception ex) { _response.ErrorInfo = "Failed to save supplier outlet Mapping.\n" + ex.Message; _log.Error("Failed tosave supplier outlet Mapping", ex); } return _response; }
public HttpResponseMessage SaveOutletFarmerMapping(CostCentreMapping centreMapping) { var response = new ResponseBool { Success = false }; try { _costCentreRepository.SaveMapping(centreMapping); response.Success = true; response.ErrorInfo = "Successfully Save Farmer Outlet Mapping"; } catch (DomainValidationException dve) { string errorMsg = dve.ValidationResults.Results.Aggregate("Error: In entity fields.\n", (current, msg) => current + ("\t- " + msg.ErrorMessage + "\n")); response.ErrorInfo = errorMsg; _log.Error(errorMsg, dve); } catch (Exception ex) //any other { response.ErrorInfo = "Error: An error occurred when deleting the entity."; _log.Error("Error: An error occurred when deleting the entity.", ex); } return Request.CreateResponse(HttpStatusCode.OK, response); }