public ActionResult Create([Bind(Include = "ID,Name")] MenuGroup menuGroup) { if (ModelState.IsValid) { db.MenuGroups.Add(menuGroup); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(menuGroup)); }
public ActionResult Create([Bind(Include = "Username,Password,FullName,Photo")] Admin admin) { if (ModelState.IsValid) { db.Admins.Add(admin); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(admin)); }
public ActionResult Create([Bind(Include = "Username,Password,ConfirmPassword,FullName,Address,Email,Photo,ID")] Customer customer) { if (ModelState.IsValid) { db.Customers.Add(customer); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Create([Bind(Include = "ID,Name,Alias,CategoryID,Image,MoreImages,Price,PromotionPrice,Warranty,Description,Content,HomeFlag,HotFlag,ViewCount,CreatedDate,CreatedBy,UpdatedDate,UpdatedBy,MetaKeyword,MetaDescription,Status")] Product product) { if (ModelState.IsValid) { db.Products.Add(product); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryID = new SelectList(db.ProductCategories, "ID", "Name", product.CategoryID); return(View(product)); }
public ActionResult DangKy(DangNhap_DangKy model) { //var db = new ShopEntities(); model.Customer.Username = model.Customer.Email; using (QuoKaNaDBContext db = new QuoKaNaDBContext()) { if (db.Customers.Any(x => x.Username == model.Customer.Username)) { ViewBag.DuplicateMessage = "Tên đăng nhập đã tồn tại."; return(View("../Home/TrangChuIndex")); //return Content(ViewBag); } // model.Photo = model.Photo.ToString(); db.Customers.Add(model.Customer); db.SaveChanges(); } ModelState.Clear(); ViewBag.SuccessMessage = "Đăng ký thành công."; return(View("../Users/Index")); }