示例#1
0
        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));
                }
            }
        }
示例#2
0
        public ActionResult Confirm(employee employeemodel, string id)
        {
            Conn conn = new Conn();

            using (quickmenusubEntities db = new quickmenusubEntities(conn.ConfConn(id)))
            {
                var UserConfirmation = db.employee.Where(x => x.email == employeemodel.email && x.password == employeemodel.password).FirstOrDefault();
                if (UserConfirmation == null)
                {
                    employeemodel.LoginError = "Wrong Email or Password";
                    employeemodel.password   = null;
                    return(View("_TemLog", employeemodel));
                }
                else
                {
                    Session["email"]    = UserConfirmation.email;
                    Session["name"]     = UserConfirmation.name;
                    Session["position"] = UserConfirmation.position;
                    Session["rname"]    = id;
                    if (UserConfirmation.position == "Gerente")
                    {
                        return(RedirectToAction("Index", "Management"));
                    }
                    else if (UserConfirmation.position == "Camarero" || UserConfirmation.position == "Personal Cocina")
                    {
                        return(RedirectToAction("Index", "Order"));
                    }
                    else
                    {
                        return(Redirect("/Template/Index/" + id));
                    }
                }
            }
        }
示例#3
0
        public OrdersLoading(string name)
        {
            rname = name;
            Conn conn = new Conn();

            using (quickmenusubEntities db = new quickmenusubEntities(conn.ConfConn(rname)))
            {
                var GetOrders = db.order.Where(x => x.idorder > 0);
                foreach (var r in GetOrders)
                {
                    orders.Add(r);
                }
            }
        }
示例#4
0
        public ShoppingCartLoading(List <orderdetail> od, string name)
        {
            rname        = name;
            orderdetails = od;
            Conn conn = new Conn();

            foreach (var r in orderdetails)
            {
                using (quickmenusubEntities dbp = new quickmenusubEntities(conn.ConfConn(rname)))
                {
                    var Getpname = dbp.product.Where(x => x.idproduct == r.idproduct).First();
                    pnames.Add(Getpname);
                }
            }
        }
示例#5
0
        public TemplateLoading(string name)
        {
            rname = name;
            Conn conn = new Conn();

            using (quickmenusubEntities db = new quickmenusubEntities(conn.ConfConn(rname)))
            {
                pagestyle = db.pagestyle.Where(x => x.restaurantname == rname).FirstOrDefault();
                var GetProducts = db.product.Where(x => x.idproduct > 0);
                foreach (var r in GetProducts)
                {
                    products.Add(r);
                }
            }
        }
示例#6
0
        public DetailsLoading(string name, int id)
        {
            rname = name;
            Conn conn = new Conn();

            using (quickmenusubEntities db = new quickmenusubEntities(conn.ConfConn(rname)))
            {
                order = db.order.Find(id);
            }
            using (quickmenusubEntities db = new quickmenusubEntities(conn.ConfConn(rname)))
            {
                var GetOD = db.orderdetail.Where(x => x.idorder == id);
                foreach (var r in GetOD)
                {
                    product Getpname;
                    using (quickmenusubEntities dbp = new quickmenusubEntities(conn.ConfConn(rname)))
                    {
                        Getpname = dbp.product.Where(x => x.idproduct == r.idproduct).First();
                    }
                    pnames.Add(Getpname);
                    orderdetails.Add(r);
                }
            }
        }
示例#7
0
        public ManagementLoading(string name)
        {
            rname = name;
            Conn conn = new Conn();

            using (quickmenusubEntities db = new quickmenusubEntities(conn.ConfConn(rname)))
            {
                var GetProducts  = db.product.Where(x => x.idproduct > 0);
                var GetEmployees = db.employee.Where(x => x.email != null);
                foreach (var r in GetProducts)
                {
                    products.Add(r);
                }
                foreach (var r in GetEmployees)
                {
                    employees.Add(r);
                }
            }
        }
示例#8
0
        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));
                }
            }
        }
示例#9
0
        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));
                }
            }
        }
示例#10
0
        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));
                }
            }
        }
示例#11
0
        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));
                }
            }
        }