Пример #1
0
        public async Task Update(Guid id, ProductAddUpdateModel model)
        {
            var product = new Product()
            {
                Id                 = id,
                ProductBrand       = model.ProductBrand,
                ProductCategory    = model.ProductCategory,
                ProductDescription = model.ProductDescription,
                ProductName        = model.ProductName,
                ProductPrice       = model.ProductPrice,
                ProductTag         = model.ProductTag,
                ProductType        = model.ProductType,
                ProductWeight      = model.ProductWeight
            };

            await _products.ReplaceOneAsync(x => x.Id == id, product);
        }
Пример #2
0
        public async Task <Guid> Create(ProductAddUpdateModel model)
        {
            Guid productId = Guid.NewGuid();

            var product = new Product()
            {
                Id                 = productId,
                ProductBrand       = model.ProductBrand,
                ProductCategory    = model.ProductCategory,
                ProductDescription = model.ProductDescription,
                ProductName        = model.ProductName,
                ProductPrice       = model.ProductPrice,
                ProductTag         = model.ProductTag,
                ProductType        = model.ProductType,
                ProductWeight      = model.ProductWeight
            };

            await _products.InsertOneAsync(product);

            return(productId);
        }
        public async Task <IActionResult> Update(Guid id, ProductAddUpdateModel model)
        {
            await _productService.Update(id, model);

            return(Ok());
        }
 public async Task <ActionResult <Guid> > Create(ProductAddUpdateModel model)
 {
     return(await _productService.Create(model));
 }