public ActionResult Create(Dish dish, int[] ingredients) { Dish newDish = new Dish(); newDish.DishName = dish.DishName; newDish.Category = dish.Category; newDish.Price = dish.Price; newDish.Weight = dish.Weight; newDish.Note = dish.Note; newDish.Popularity = 0; newDish.Ingredients.Clear(); if (ingredients != null) { //получаем выбранные курсы foreach (var c in db.Ingredients.Where(co => ingredients.Contains(co.Id))) { newDish.Ingredients.Add(c); } } db.Dishes.Add(newDish); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "Id,Email,Password,LName,FName,Sex,Visit")] User user) { if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Create([Bind(Include = "Id,IngredientName")] Ingredient ingredient) { if (ModelState.IsValid) { db.Ingredients.Add(ingredient); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ingredient)); }
public ActionResult Create(MenuItem menuitem) { if (ModelState.IsValid) { db.MenuItems.Add(menuitem); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(menuitem)); }
public ActionResult Create(Statistics statistics) { if (ModelState.IsValid) { db.Statistics.Add(statistics); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(statistics)); }
public ActionResult Create(UserProfile userprofile) { if (ModelState.IsValid) { db.UserProfiles.Add(userprofile); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userprofile)); }
public ActionResult Create(Order order) { if (ModelState.IsValid) { db.Orders.Add(order); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(order)); }
public ActionResult Create([Bind(Include = "Id,DateOfMenu,AdminId")] Menu menu) { if (ModelState.IsValid) { db.Menus.Add(menu); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AdminId = new SelectList(db.Admins, "Id", "Login", menu.AdminId); return(View(menu)); }
public ActionResult Create([Bind(Include = "Id,DateOfZakaz,UserId")] Zakaz zakaz) { if (ModelState.IsValid) { db.Zakazs.Add(zakaz); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.Users, "Id", "Email", zakaz.UserId); return(View(zakaz)); }
public ActionResult DeleteUser(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } User user = db.Users.Find(id); if (user == null) { return(HttpNotFound()); } db.Users.Remove(user); db.SaveChanges(); return(RedirectToAction("Users")); }
public ActionResult Register([Bind(Include = "Id,Email,Password,LName,FName,Sex,Visit")] User user) { if (ModelState.IsValid) { if (db.Users.Where(c => c.Email == user.Email).ToList().Count == 0) { ViewBag.RegisterFaultMessage = null; db.Users.Add(user); db.SaveChanges(); Session["user"] = user; return(RedirectToAction("Index", "Users")); } else { ViewBag.RegisterFaultMessage = "Логин " + user.Email + " уже существует. Пожалуйста, выберите другой"; return(View("Index")); } } return(View("Index")); }
// PUT api/Default1/5 public HttpResponseMessage PutOrder(int id, Order order) { if (ModelState.IsValid && id == order.OrderId) { db.Entry(order).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public ActionResult AddMenu([ModelBinder(typeof(MenuBinder))] Menu menu, int[] Dish_Ids) { menu.Dishes.Clear(); if (Dish_Ids != null) { foreach (var c in db.Dishes.Where(c => Dish_Ids.Contains(c.Id))) { menu.Dishes.Add(c); } } db.Menus.Add(menu); db.SaveChanges(); //Admin admin = db.Admins.Where(c => c.Id == menu.AdminId).ToList().First(); //string adminName = admin.Login; var listuser = db.Users.Where(c => c.Email != null).ToList(); foreach (User r in listuser) { //string email = user.Email.All; new EmailSender(r.Email, menu.DateOfMenu.ToShortDateString() + " " + menu.DateOfMenu.ToShortTimeString()).send(); } return(RedirectToAction("Menus", "Admins")); }
public ActionResult ExternalLoginConfirmation(RegisterExternalLoginModel model, string returnUrl) { string provider = null; string providerUserId = null; if (User.Identity.IsAuthenticated || !OAuthWebSecurity.TryDeserializeProviderUserId(model.ExternalLoginData, out provider, out providerUserId)) { return(RedirectToAction("Manage")); } if (ModelState.IsValid) { // Insert a new user into the database using (CanteenContext db = new CanteenContext()) { UserProfile user = db.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower()); // Check if user already exists if (user == null) { // Insert name into the profile table db.UserProfiles.Add(new UserProfile { UserName = model.UserName }); db.SaveChanges(); OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName); OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false); return(RedirectToLocal(returnUrl)); } else { ModelState.AddModelError("UserName", "User name already exists. Please enter a different user name."); } } } ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(provider).DisplayName; ViewBag.ReturnUrl = returnUrl; return(View(model)); }
public ActionResult Index() { db.SaveChanges(); return(View()); }