public ActionResult Create(Tax tax) { if (ModelState.IsValid) { db.Taxes.Add(tax); db.SaveChanges(); return(RedirectToAction("Index", "Register")); } return(View(tax)); }
public ActionResult Create(Discount discount) { if (ModelState.IsValid) { db.Discounts.Add(discount); db.SaveChanges(); return(RedirectToAction("Index", "Register")); } return(View(discount)); }
public ActionResult Create(MenuItem menuitem) { if (ModelState.IsValid) { db.MenuItems.Add(menuitem); db.SaveChanges(); return(RedirectToAction("Index", "Register")); } return(View(menuitem)); }
public ActionResult Create(PoS.Models.ViewModels.UserView user) { if (ModelState.IsValid) { _context.Users.Add(new Models.User { Name = user.Name, Surename = user.Nazwisko, City = _context.Cities.First(x => x.ID == user.CityID), Email = user.Email }); _context.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Create(User user) { if (ModelState.IsValid) { //validate username does not already exist var validate = db.Users.FirstOrDefault(x => x.UserName == user.UserName); if (validate == null) { db.Users.Add(user); db.SaveChanges(); FormsAuthentication.SetAuthCookie(user.UserName.ToString(), true); HttpCookie UserCookie = new HttpCookie("UserCookie"); UserCookie.Values.Add("LastName", user.LastName); UserCookie.Values.Add("FirstName", user.FirstName); Response.Cookies.Add(UserCookie); return(RedirectToAction("Index", "Register")); } else //kick back to register page { ModelState.AddModelError("", "Username is taken"); } return(View(user)); } return(View(user)); }
public ActionResult Create(PoS.Models.ViewModels.PostView post) { if (ModelState.IsValid) { _context.Posts.Add(new Models.Post { Title = post.Title, Content = post.Content, CityID = _context.Cities.First(x => x.ID == post.CityID), User = _context.Users.First(x => x.ID == post.UserID) }); _context.SaveChanges(); return(RedirectToAction("Index")); } return(View(post)); }
public int Commit() { int oRetStat = 0; _context.SaveChanges(); return(oRetStat); }
public ActionResult Create(OrderDetails order) { order.OrderDate = DateTime.Now; if (ModelState.IsValid) { db.OrderDetails.Add(order); db.SaveChanges(); //go to Order history page return(RedirectToAction("Index")); } return(RedirectToAction("Index", "Register")); }