Ejemplo n.º 1
0
 private void AddNew_Button_Click(object sender, EventArgs e)
 {
     MasterData.Add(new Users
     {
         Status = ModifyMode.Insert
     });
 }
Ejemplo n.º 2
0
        public async Task <ProductForDetail> CreateProduct(ProductForCreation productDto)
        {
            var checkUrlSeoExist = _db.Products.Where(p => p.UrlSeo == productDto.UrlSeo);

            if (checkUrlSeoExist == null)
            {
                //add product in db
                Product productToReturn = new Product
                {
                    Id             = productDto.Id,
                    ProductName    = productDto.ProductName,
                    Price          = productDto.Price,
                    CategoryId     = productDto.CategoryId,
                    PhotoUrl       = productDto.PhotoUrl,
                    Description    = productDto.Description,
                    ProductDetails = productDto.ProductDetails,
                    Weight         = productDto.Weight,
                    Company        = productDto.Company,
                    UrlSeo         = productDto.UrlSeo
                };
                _db.Add(productToReturn);
                await _db.SaveChangesAsync();

                return(new ProductForDetail
                {
                    Id = productToReturn.Id,
                    ProductName = productToReturn.ProductName,
                    CategoryId = productToReturn.CategoryId,
                    Price = productToReturn.Price,
                    Description = productToReturn.Description,
                    ProductDetails = productToReturn.ProductDetails,
                    Weight = productToReturn.Weight,
                    Company = productToReturn.Company,
                    UrlSeo = productToReturn.UrlSeo,
                    Photos = null
                });
            }
            return(null);
        }