Example #1
0
 public ActionResult Confirm(employee employeemodel)
 {
     using (restaurantsdbEntities db = new restaurantsdbEntities())
     {
         var UserConfirmation = db.employees.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;
             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/"));
             }
         }
     }
 }
Example #2
0
        public OrdFinishLoading(List <orderdetail> od)
        {
            orderdetails = od;


            foreach (var r in orderdetails)
            {
                using (restaurantsdbEntities dbp = new restaurantsdbEntities())
                {
                    var Getpname = dbp.products.Where(x => x.IDProduct == r.Product_IDProduct).First();
                    pnames.Add(Getpname);
                }
                using (restaurantsdbEntities dbp = new restaurantsdbEntities())
                {
                    try
                    {
                        var Getlastid = dbp.orders.Last();
                        order.IDOrder = (Getlastid.IDOrder) + 1;
                    }
                    catch
                    {
                        order.IDOrder = 1;
                    }
                }
            }
        }
 public ActionResult AddPro(product productmodel)
 {
     using (restaurantsdbEntities db = new restaurantsdbEntities())
     {
         try
         {
             int     idp;
             product LastProduct;
             try
             {
                 LastProduct = db.products.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));
         }
     }
 }
Example #4
0
 public OrdersLoading()
 {
     using (restaurantsdbEntities db = new restaurantsdbEntities())
     {
         var GetOrders = db.orders.Where(x => x.IDOrder > 0);
         foreach (var r in GetOrders)
         {
             orders.Add(r);
         }
     }
 }
Example #5
0
 public TemplateLoading()
 {
     using (restaurantsdbEntities db = new restaurantsdbEntities())
     {
         var GetProducts = db.products.Where(x => x.IDProduct > 0);
         foreach (var r in GetProducts)
         {
             products.Add(r);
         }
     }
 }
Example #6
0
        public ShoppingCartLoading(List <orderdetail> od)
        {
            orderdetails = od;


            foreach (var r in orderdetails)
            {
                using (restaurantsdbEntities dbp = new restaurantsdbEntities())
                {
                    var Getpname = dbp.products.Where(x => x.IDProduct == r.Product_IDProduct).First();
                    pnames.Add(Getpname);
                }
            }
        }
Example #7
0
 public ManagementLoading()
 {
     using (restaurantsdbEntities db = new restaurantsdbEntities())
     {
         var GetProducts  = db.products.Where(x => x.IDProduct > 0);
         var GetEmployees = db.employees.Where(x => x.Email != null);
         foreach (var r in GetProducts)
         {
             products.Add(r);
         }
         foreach (var r in GetEmployees)
         {
             employees.Add(r);
         }
     }
 }
Example #8
0
 public ActionResult UpdateOrd(order ordermodel)
 {
     using (restaurantsdbEntities db = new restaurantsdbEntities())
     {
         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)
 {
     using (restaurantsdbEntities db = new restaurantsdbEntities())
     {
         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)
 {
     using (restaurantsdbEntities db = new restaurantsdbEntities())
     {
         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)
 {
     using (restaurantsdbEntities db = new restaurantsdbEntities())
     {
         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));
         }
     }
 }
Example #12
0
 public DetailsLoading(int id)
 {
     using (restaurantsdbEntities db = new restaurantsdbEntities())
     {
         order = db.orders.Find(id);
     }
     using (restaurantsdbEntities db = new restaurantsdbEntities())
     {
         var GetOD = db.orderdetails.Where(x => x.IDOrder == id);
         foreach (var r in GetOD)
         {
             product Getpname;
             using (restaurantsdbEntities dbp = new restaurantsdbEntities())
             {
                 Getpname = dbp.products.Where(x => x.IDProduct == r.Product_IDProduct).First();
             }
             pnames.Add(Getpname);
             orderdetails.Add(r);
         }
     }
 }