public static ProductCode ToDomain(this ProductCodeDto code, ProductCode originalCode = null) { if (originalCode != null && originalCode.Id == code.Id) { originalCode.Name = code.Name; originalCode.Code = code.Code; originalCode.Excess = code.Excess; originalCode.HospitalRanking = code.HospitalRanking; originalCode.ExtrasRanking = code.ExtrasRanking; ((IDataDto)code).ToDomain((IData)originalCode); return(originalCode); } var data = new ProductCode { Name = code.Name, Code = code.Code, Excess = code.Excess, HospitalRanking = code.HospitalRanking, ExtrasRanking = code.ExtrasRanking }; ((IDataDto)code).ToDomain((IData)data); return(data); }
public static ProductCodeDto ToDto(this ProductCode code) { code.Ancillaries?.ForEach(v => v.ProdutCodeId = code.Id); var dto = new ProductCodeDto { Id = code.Id, UniqueId = Guid.NewGuid(), Name = code.Name, Code = code.Code, Excess = code.Excess, HospitalRanking = code.HospitalRanking, ExtrasRanking = code.ExtrasRanking, Ancillaries = code.Ancillaries?.Select(v => v.ToDto()).ToList() }; ((IData)code).ToDto((IDataDto)dto); return(dto); }
public ResponseDto Save(ProductCodeDto saveDto) { ResponseDto responseDto = new ResponseDto(); ProductCodeBo saveBo = new ProductCodeBo() { Code = saveDto.Code, ProductCodeTypeId = saveDto.ProductCodeTypeId, ProductId = saveDto.ProductId, Session = Session }; ResponseBo responseBo = productCodeBusiness.Save(saveBo); responseDto = responseBo.ToResponseDto(); return(responseDto); }
public void Post() { try { using (var server = TestServer.Create <MyStartup>()) { var dto = new ProductCodeDto { Id = 0, Name = "Product Suite 1", Code = "AH2" }; HttpResponseMessage response; response = server.HttpClient.PostAsJsonAsync("api/ProductCode", dto).Result; } } catch (Exception ex) { } }