public async Task<ResponseBool> CommodityOwnerAddAsync(CommodityOwnerDTO commodityOwnerdto) { ResponseBool _response = new ResponseBool { Success = false, ErrorInfo = "" }; string url = string.Format("api/pushmasterdata/commodityowner/save"); var httpClient = setupHttpClient(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); try { var response = await httpClient.PostAsJsonAsync(url, commodityOwnerdto); var _responseBasic = await response.Content.ReadAsAsync<ResponseBasic>(); if (_responseBasic != null && _responseBasic.ErrorInfo == "OK") { _response = new ResponseBool { Success = true }; } else { _response = new ResponseBool { Success = false, ErrorInfo = _responseBasic.ErrorInfo ?? "" }; } } catch (Exception ex) { _response.ErrorInfo = "Error: An error occurred when editing the commodity supplier.\nCause: " + ex.Message; _log.Error("Failed to edit commodity supplier.", ex); } return _response; }
public CommodityOwner Map(CommodityOwnerDTO dto) { if (dto == null) return null; var commodityOwner = Mapper.Map<CommodityOwnerDTO, CommodityOwner>(dto); commodityOwner.CommodityOwnerType = _commodityOwnerTypeRepository.GetById(dto.CommodityOwnerTypeId); commodityOwner.CommoditySupplier = _commoditySupplierRepository.GetById(dto.CommoditySupplierId) as CommoditySupplier; /*commodityOwner.MaritalStatus = _maritalStatusRepository.GetById(dto.MaritalStatusId);*/ return commodityOwner; }