public ActionResult Create([Bind(Include = "CategoryId,ID,ProductId,ProductName,ProductPrice,OldPrice,OfferBadge,CreatedDate,ModifiedDate,ProductImageUrl,ProductUrl")] Product product)
        {
            if (ModelState.IsValid)
            {
                product.CreatedDate  = DateTime.UtcNow;
                product.ModifiedDate = DateTime.UtcNow;
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(product));
        }
示例#2
0
        public void SaveProducts(List <Product> products)
        {
            ImeshmaEntities _db = new ImeshmaEntities();

            _db.Products.AddRange(products);
            _db.SaveChanges();
        }
示例#3
0
        public void AddUser(UserModel model)
        {
            try
            {
                ImeshmaEntities _db = new ImeshmaEntities();
                _db.Users.Add(
                    new User()
                {
                    FirstName    = model.FirstName,
                    LastName     = model.LastName,
                    Email        = model.Email,
                    CreatedDate  = DateTime.UtcNow,
                    ModifiedDate = DateTime.UtcNow,
                    LoginVia     = model.LoginVia
                }
                    );

                _db.SaveChanges();
            }
            catch
            {
                throw;
            }
        }