Exemple #1
0
        public IActionResult Put([FromBody] ProductCategoryAllowedSizeUpdateCommandInputDTO model)
        {
            var appResult = this.UpdateCommand.Execute(model);

            return(appResult.IsSucceed ? (IActionResult)this.Ok(appResult) : (IActionResult)this.BadRequest(appResult));
        }
        public OperationResponse <ProductCategoryAllowedSizeUpdateCommandOutputDTO> Execute(ProductCategoryAllowedSizeUpdateCommandInputDTO input)
        {
            var result = new OperationResponse <ProductCategoryAllowedSizeUpdateCommandOutputDTO>();

            using (var dbContextScope = this.DbContextScopeFactory.Create())
            {
                var getByIdResult = this.Repository.GetById(input.Id);
                result.AddResponse(getByIdResult);
                if (result.IsSucceed)
                {
                    getByIdResult.Bag.Size = input.Size;

                    try
                    {
                        dbContextScope.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        result.AddError("Error updating Product Allowed Color Type Color Type", ex);
                    }

                    getByIdResult = this.Repository.GetById(input.Id);
                    result.AddResponse(getByIdResult);
                    if (result.IsSucceed)
                    {
                        result.Bag = new ProductCategoryAllowedSizeUpdateCommandOutputDTO
                        {
                            Id = getByIdResult.Bag.Id,
                            ProductCategoryId = getByIdResult.Bag.ProductCategoryId,
                            Size = getByIdResult.Bag.Size,
                        };
                    }
                }
            }

            return(result);
        }