public IActionResult Post([FromBody] ProductCategoryAllowedSizeInsertCommandInputDTO model) { var appResult = this.InsertCommand.Execute(model); if (appResult.IsSucceed) { var signalArgs = new SignalREventArgs(SignalREvents.DATA_CHANGED.Identifier, nameof(SignalREvents.DATA_CHANGED.ActionEnum.ADDED_ITEM), nameof(ProductCategoryAllowedColorType), appResult.Bag); this.SignalRHubContext.Clients.All.DataChanged(signalArgs); } return(appResult.IsSucceed ? (IActionResult)this.Ok(appResult) : (IActionResult)this.BadRequest(appResult)); }
public OperationResponse <ProductCategoryAllowedSizeInsertCommandOutputDTO> Execute(ProductCategoryAllowedSizeInsertCommandInputDTO input) { var result = new OperationResponse <ProductCategoryAllowedSizeInsertCommandOutputDTO>(); using (var dbContextScope = this.DbContextScopeFactory.Create()) { var entity = new DomainModel.Product.ProductCategoryAllowedSize { ProductCategoryId = input.ProductCategoryId, Size = input.Size, }; try { var insertResult = this.Repository.Insert(entity); result.AddResponse(insertResult); if (result.IsSucceed) { dbContextScope.SaveChanges(); } } catch (Exception ex) { result.AddError("Error Adding Product Allowed Color Type", ex); } if (result.IsSucceed) { var getByIdResult = this.Repository.GetById(entity.Id); result.AddResponse(getByIdResult); if (result.IsSucceed) { result.Bag = new ProductCategoryAllowedSizeInsertCommandOutputDTO { Id = getByIdResult.Bag.Id, ProductCategoryId = getByIdResult.Bag.ProductCategoryId, Size = getByIdResult.Bag.Size, }; } } } return(result); }