public ActionResult AddPro(product productmodel) { Conn conn = new Conn(); string rname = (string)Session["rname"]; using (quickmenusubEntities db = new quickmenusubEntities(conn.ConfConn(rname))) { try { int idp; product LastProduct; try { LastProduct = db.product.Where(x => x.idproduct > 0).OrderByDescending(x => x.idproduct).First(); idp = LastProduct.idproduct + 1; } catch { idp = 1; } var ProductCreation = db.Set <product>(); ProductCreation.Add(new product { idproduct = idp, name = productmodel.name, price = productmodel.price, details = productmodel.details }); db.SaveChanges(); return(RedirectToAction("Index", "Management")); } catch (Exception ex) { productmodel.AddPError = "Couldn't create new Product" + ex; return(PartialView("_ProAdd", productmodel)); } } }
public ActionResult UpdateOrd(order ordermodel) { Conn conn = new Conn(); string rname = (string)Session["rname"]; using (quickmenusubEntities db = new quickmenusubEntities(conn.ConfConn(rname))) { if (ModelState.IsValid) { db.Entry(ordermodel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("GetOrders")); } else { ordermodel.AddOError = "Couldn't edit Order"; return(PartialView("_OrdEdit", ordermodel)); } } }
public ActionResult UpdatePro(product productmodel) { Conn conn = new Conn(); string rname = (string)Session["rname"]; using (quickmenusubEntities db = new quickmenusubEntities(conn.ConfConn(rname))) { if (ModelState.IsValid) { db.Entry(productmodel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("GetProducts")); } else { productmodel.AddPError = "Couldn't edit Product"; return(PartialView("_ProEdit", productmodel)); } } }
public ActionResult UpdateEmp(employee employeemodel) { Conn conn = new Conn(); string rname = (string)Session["rname"]; using (quickmenusubEntities db = new quickmenusubEntities(conn.ConfConn(rname))) { if (ModelState.IsValid) { db.Entry(employeemodel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("GetEmployees")); } else { employeemodel.AddEError = "Couldn't edit Employee"; return(PartialView("_EmpEdit", employeemodel)); } } }
public ActionResult AddEmp(employee employeemodel) { Conn conn = new Conn(); string rname = (string)Session["rname"]; using (quickmenusubEntities db = new quickmenusubEntities(conn.ConfConn(rname))) { try { var EmployeeCreation = db.Set <employee>(); EmployeeCreation.Add(new employee { email = employeemodel.email, password = employeemodel.password, name = employeemodel.name, position = employeemodel.position }); db.SaveChanges(); return(RedirectToAction("Index", "Management")); } catch (Exception ex) { employeemodel.AddEError = "Couldn't create new Employee" + ex; return(PartialView("_EmpAdd", employeemodel)); } } }