public IActionResult Put([FromBody] ProductCategoryUpdateCommandInputDTO model) { var appResult = this.UpdateCommand.Execute(model); if (appResult.IsSucceed) { var signalArgs = new SignalREventArgs(SignalREvents.DATA_CHANGED.Identifier, nameof(SignalREvents.DATA_CHANGED.ActionEnum.UPDATED_ITEM), "FlowerProductCategory", appResult.Bag); this.SignalRHubContext.Clients.All.DataChanged(signalArgs); } return(appResult.IsSucceed ? (IActionResult)this.Ok(appResult) : (IActionResult)this.BadRequest(appResult)); }
public OperationResponse <ProductCategoryUpdateCommandOutputDTO> Execute(ProductCategoryUpdateCommandInputDTO input) { var result = new OperationResponse <ProductCategoryUpdateCommandOutputDTO>(); using (var dbContextScope = this.DbContextScopeFactory.Create()) { var getByIdResult = this.Repository.GetById(input.Id); result.AddResponse(getByIdResult); if (result.IsSucceed) { getByIdResult.Bag.Name = input.Name; getByIdResult.Bag.Identifier = input.Identifier; getByIdResult.Bag.Id = input.Id; try { dbContextScope.SaveChanges(); } catch (Exception ex) { result.AddError("Error updating ProductCategory Color Type", ex); } getByIdResult = this.Repository.GetById(input.Id); result.AddResponse(getByIdResult); if (result.IsSucceed) { result.Bag = new ProductCategoryUpdateCommandOutputDTO { Id = getByIdResult.Bag.Id, Identifier = getByIdResult.Bag.Identifier, Name = getByIdResult.Bag.Name }; } } } return(result); }