public IActionResult Put([FromBody] SaleOpportunityTargetPriceUpdateCommandInputDTO model) { var appResult = this.UpdateCommand.Execute(model); return(appResult.IsSucceed ? (IActionResult)this.Ok(appResult) : (IActionResult)this.BadRequest(appResult)); }
public OperationResponse <SaleOpportunityTargetPriceUpdateCommandOutputDTO> Execute(SaleOpportunityTargetPriceUpdateCommandInputDTO input) { var result = new OperationResponse <SaleOpportunityTargetPriceUpdateCommandOutputDTO>(); using (var dbContextScope = this.DbContextScopeFactory.Create()) { var getByIdResult = this.Repository.GetById(input.Id); result.AddResponse(getByIdResult); if (result.IsSucceed) { getByIdResult.Bag.TargetPrice = input.TargetPrice; getByIdResult.Bag.SaleSeasonTypeId = input.SaleSeasonTypeId; getByIdResult.Bag.IsDeleted = input.IsDeleted; try { dbContextScope.SaveChanges(); } catch (Exception ex) { result.AddError("Error updating Sample Box", ex); } getByIdResult = this.Repository.GetById(input.Id); result.AddResponse(getByIdResult); if (result.IsSucceed) { result.Bag = new SaleOpportunityTargetPriceUpdateCommandOutputDTO { Id = getByIdResult.Bag.Id, TargetPrice = getByIdResult.Bag.TargetPrice, SaleSeasonTypeId = getByIdResult.Bag.SaleSeasonTypeId, SampleBoxes = getByIdResult.Bag.SampleBoxes.Select(o => o.Id), SaleOpportunityId = getByIdResult.Bag.SaleOpportunityId, SaleOpportunityTargetPriceProducts = getByIdResult.Bag.SaleOpportunityTargetPriceProducts.Select(o => o.Id), }; } } } return(result); }