public ActionResult Done(int?id, int?idd) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (idd == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var books = db.PassOrders; foreach (PassOrder b in books.ToList()) { if (b.OrderId == id) { b.Status = "Done"; //db.Entry(b).State = EntityState.Modified; db.SaveChanges(); } } var book = db.Chefs; foreach (Chef b in book.ToList()) { if (b.ChefId == idd) { b.State = "Free"; //db.Entry(b).State = EntityState.Modified; db.SaveChanges(); } } return(RedirectToAction("Welcome", "Chefs", new { id = idd })); }
public ActionResult Create([Bind(Include = "ChefId,Id,Name,State")] Chef chef) { if (ModelState.IsValid) { db.Chefs.Add(chef); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(chef)); }
public ActionResult Create([Bind(Include = "DelivererId,Id,Name")] DeliveryTeam deliveryTeam) { if (ModelState.IsValid) { db.DeliveryTeams.Add(deliveryTeam); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(deliveryTeam)); }
public ActionResult Create([Bind(Include = "CustomerId,Id,Address,Name")] Customer customer) { if (ModelState.IsValid) { db.Customers.Add(customer); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Create([Bind(Include = "CatId,Name,SupplierId")] SupplierCategory supplierCategory) { if (ModelState.IsValid) { db.SupplierCategories.Add(supplierCategory); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(supplierCategory)); }
public ActionResult Create([Bind(Include = "SupplierId,Id,Name")] Supplier supplier) { if (ModelState.IsValid) { db.Suppliers.Add(supplier); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(supplier)); }
public ActionResult Assign(int id, int idd) { PassOrder p = new PassOrder(); p.ChefId = id; p.OrderId = idd; p.Status = "Busy"; db.SaveChanges(); ViewBag.msg = "This order is assigned to this chef!"; return(RedirectToAction("ViewOrders", "Admin")); }
public ActionResult Create([Bind(Include = "OrderId")] AdminOrder adminOrder) { if (ModelState.IsValid) { db.AdminOrders.Add(adminOrder); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OrderId = new SelectList(db.AdminOrderDetails, "OrderId", "OrderId", adminOrder.OrderId); return(View(adminOrder)); }
public ActionResult Create([Bind(Include = "ItemId,CategoryId,Name,Description,Price,Quantity,Image")] ItemsDetail itemsDetail) { if (ModelState.IsValid) { db.ItemsDetails.Add(itemsDetail); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", itemsDetail.CategoryId); return(View(itemsDetail)); }
public ActionResult ViewItems(int id) { SupplierCategory cat = db.SupplierCategories.Find(id); if (cat == null) { return(HttpNotFound()); } AdminOrder a = new AdminOrder { OrderId = id }; db.SaveChanges(); ViewBag.Message = a; return(View(cat)); }
public ActionResult Create1([Bind(Include = "CategoryId,Name,Description,Price,Quantity,ImageFile")] ItemsDetail itemsDetail) { if (ModelState.IsValid) { string fileName = Path.GetFileNameWithoutExtension(itemsDetail.ImageFile.FileName); string extension = Path.GetExtension(itemsDetail.ImageFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; itemsDetail.Image = "~/Images/" + fileName; var supportedType = new[] { "jpg", "jpeg", "png" }; if (!supportedType.Contains(extension)) { fileName = Path.Combine(Server.MapPath("~/Images/"), fileName); itemsDetail.ImageFile.SaveAs(fileName); db.ItemsDetails.Add(itemsDetail); db.SaveChanges(); return(RedirectToAction("ViewItems", new { id = itemsDetail.CategoryId })); } else { ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", itemsDetail.CategoryId); return(View(itemsDetail)); } } ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", itemsDetail.CategoryId); return(View(itemsDetail)); }
// GET: DeliveryTeams/Details/5 public ActionResult Done(int?id, int?idd) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (idd == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var books = db.AssignOrders; foreach (AssignOrder b in books.ToList()) { if (b.OrderId == id) { b.Status = "Delivered"; //db.Entry(b).State = EntityState.Modified; db.SaveChanges(); } } var book = db.OrderDetails; foreach (OrderDetail b in book.ToList()) { if (b.OrderId == id) { b.State = "Done"; //db.Entry(b).State = EntityState.Modified; db.SaveChanges(); } } return(RedirectToAction("Welcome", "DeliveryTeams", new { id = idd })); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.FName, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); if (model.roles == "Customer") { DB22Entities3 db1 = new DB22Entities3(); Customer cus = new Customer(); cus.Address = model.address; cus.Id = user.Id; cus.Name = model.FName; db1.Customers.Add(cus); db1.SaveChanges(); await UserManager.AddToRoleAsync(user.Id, "Customer"); db1.SaveChanges(); return(RedirectToAction("Welcome", "Customers", new { id = user.Id })); } else if (model.roles == "Chef") { DB22Entities3 db1 = new DB22Entities3(); Chef che = new Chef(); che.Id = user.Id; che.Name = model.FName; db1.Chefs.Add(che); db1.SaveChanges(); await UserManager.AddToRoleAsync(user.Id, "Chef"); //db1.SaveChanges(); return(RedirectToAction("Welcome", "Chefs", new { id = user.Id })); } else if (model.roles == "Supplier") { DB22Entities3 db1 = new DB22Entities3(); Supplier che = new Supplier(); che.Id = user.Id; che.Name = model.FName; db1.Suppliers.Add(che); db1.SaveChanges(); await UserManager.AddToRoleAsync(user.Id, "Supplier"); //db1.SaveChanges(); return(RedirectToAction("Welcome", "Suppliers")); } else if (model.roles == "Delivery") { DB22Entities3 db1 = new DB22Entities3(); DeliveryTeam che = new DeliveryTeam(); che.Id = user.Id; che.Name = model.FName; db1.DeliveryTeams.Add(che); db1.SaveChanges(); await UserManager.AddToRoleAsync(user.Id, "Delivery"); //db1.SaveChanges(); return(RedirectToAction("Welcome", "DeliveryTeam", new { id = user.Id })); } else { return(View(model)); } } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult Assign(int id) { g = Convert.ToInt32(TempData["id"]); PassOrder p = new PassOrder(); p.ChefId = id; p.OrderId = g; p.Status = "Inprogress"; db.PassOrders.Add(p); db.SaveChanges(); return(RedirectToAction("ViewOrders", "Admin")); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.FName, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); if (model.roles == "Customer") { DB22Entities3 db1 = new DB22Entities3(); Customer cus = new Customer(); cus.Address = model.address; cus.Id = user.Id; cus.Name = model.FName; db1.Customers.Add(cus); db1.SaveChanges(); await UserManager.AddToRoleAsync(user.Id, "Customer"); db1.SaveChanges(); return(RedirectToAction("Index", "Home")); } else if (model.roles == "Chef") { DB22Entities3 db1 = new DB22Entities3(); Chef che = new Chef(); che.Id = user.Id; che.Name = model.FName; db1.Chefs.Add(che); try { db1.SaveChanges(); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } await UserManager.AddToRoleAsync(user.Id, "Chef"); //db1.SaveChanges(); return(RedirectToAction("Index", "Home")); } else if (model.roles == "Supplier") { DB22Entities3 db1 = new DB22Entities3(); Supplier che = new Supplier(); che.Id = user.Id; che.Name = model.FName; db1.Suppliers.Add(che); db1.SaveChanges(); await UserManager.AddToRoleAsync(user.Id, "Supplier"); return(RedirectToAction("Welcome", "Suppliers", new { id = user.Id })); } else if (model.roles == "Delivery") { DB22Entities3 db1 = new DB22Entities3(); DeliveryTeam che = new DeliveryTeam(); che.Id = user.Id; che.Name = model.FName; db1.DeliveryTeams.Add(che); db1.SaveChanges(); await UserManager.AddToRoleAsync(user.Id, "Delivery"); //db1.SaveChanges(); return(RedirectToAction("Index", "Home")); } else { return(View(model)); } } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult Welcome(Customer model) { Customer customer = db.Customers.Find(model.CustomerId); customer.Address = model.Address; db.SaveChanges(); return(RedirectToAction("cWelcome", new { id = customer.CustomerId })); }