public OperationResponse <CustomerThirdPartyAppSettingUpdateCommandOutputDTO> Execute(CustomerThirdPartyAppSettingUpdateCommandInputDTO input) { var result = new OperationResponse <CustomerThirdPartyAppSettingUpdateCommandOutputDTO>(); using (var dbContextScope = this.DbContextScopeFactory.Create()) { var getByIdResult = this.Repository.GetById(input.Id); result.AddResponse(getByIdResult); if (result.IsSucceed) { getByIdResult.Bag.CustomerId = input.CustomerId; getByIdResult.Bag.ThirdPartyAppTypeId = input.ThirdPartyAppTypeId; getByIdResult.Bag.ThirdPartyCustomerId = input.ThirdPartyCustomerId; try { dbContextScope.SaveChanges(); } catch (Exception ex) { result.AddError("Error updating Product Color Type", ex); } getByIdResult = this.Repository.GetById(input.Id); result.AddResponse(getByIdResult); if (result.IsSucceed) { result.Bag = new CustomerThirdPartyAppSettingUpdateCommandOutputDTO { Id = getByIdResult.Bag.Id, CustomerId = getByIdResult.Bag.CustomerId, CustomerName = getByIdResult.Bag.Customer.Name, ThirdPartyAppTypeId = getByIdResult.Bag.ThirdPartyAppTypeId, ThirdPartyCustomerId = getByIdResult.Bag.ThirdPartyCustomerId, }; } } } return(result); }
public IActionResult Put([FromBody] CustomerThirdPartyAppSettingUpdateCommandInputDTO model) { var appResult = this.UpdateCommand.Execute(model); return(appResult.IsSucceed ? (IActionResult)this.Ok(appResult) : (IActionResult)this.BadRequest(appResult)); }