public async Task <Result> UpdateProductAttributeAsync(AttributeResponseModel model, Guid id)
        {
            var productAttribute = await Data.ProductAttribute.FindAsync(id).ConfigureAwait(false);

            if (productAttribute == null)
            {
                return(NotFound);
            }

            productAttribute.Name          = model.Name;
            productAttribute.Color         = model.Color;
            productAttribute.Size          = model.Size;
            productAttribute.Photo         = model.Photo;
            productAttribute.StockQuantity = model.StockQuantity;
            productAttribute.Price         = model.Price;

            await Data.SaveChangesAsync().ConfigureAwait(false);

            return(Result.Success);
        }
        public async Task <Result> AddProductAttributeAsync(AttributeResponseModel model, Guid productId,
                                                            bool saveChange = true)
        {
            var productAttribute = new ProductAttribute
            {
                ProductId     = productId,
                Name          = model.Name,
                Color         = model.Color,
                Size          = model.Size,
                Photo         = model.Photo,
                StockQuantity = model.StockQuantity,
                Price         = model.Price
            };

            await Data.ProductAttribute.AddAsync(productAttribute).ConfigureAwait(false);

            if (saveChange)
            {
                await Data.SaveChangesAsync().ConfigureAwait(false);
            }

            return(Result.Success);
        }
 public async Task <ActionResult> Update(AttributeResponseModel model, Guid id)
 {
     return(await _products
            .UpdateProductAttributeAsync(model, id)
            .ToActionResult());
 }