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)); }
public void SaveProducts(List <Product> products) { ImeshmaEntities _db = new ImeshmaEntities(); _db.Products.AddRange(products); _db.SaveChanges(); }
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; } }