public IActionResult Put([FromBody] BasicProductAliasUpdateCommandInputDTO 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), nameof(DomainModel.Product.BasicProductAlias), appResult.Bag); this.SignalRHubContext.Clients.All.DataChanged(signalArgs); } return(appResult.IsSucceed ? (IActionResult)this.Ok(appResult) : (IActionResult)this.BadRequest(appResult)); }
public OperationResponse <BasicProductAliasUpdateCommandOutputDTO> Execute(BasicProductAliasUpdateCommandInputDTO input) { var result = new OperationResponse <BasicProductAliasUpdateCommandOutputDTO>(); using (var dbContextScope = this.DbContextScopeFactory.Create()) { var getByIdResult = this.Repository.GetById(input.Id); result.AddResponse(getByIdResult); if (result.IsSucceed) { getByIdResult.Bag.Name = input.Name; 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 BasicProductAliasUpdateCommandOutputDTO { Id = getByIdResult.Bag.Id, Name = getByIdResult.Bag.Name }; } } } return(result); }