public ActionResult Login(LoginViewModel l, string ReturnUrl = "")
 {
     using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
     {
         var users = db.tblUsers.Where(a => a.Username == l.Username && a.Password == l.Password).FirstOrDefault();
         if (users != null)
         {
             Session.Add("img", users.Photo);
             Session.Add("username", users.Username);
             FormsAuthentication.SetAuthCookie(l.Username, true);
             if (Url.IsLocalUrl(ReturnUrl))
             {
                 return(Redirect(ReturnUrl));
             }
             else
             {
                 Session.Add("userid", users.UserId);
                 if (users.UserRoles.Where(r => r.RoleId == 1).FirstOrDefault() != null)
                 {
                     return(RedirectToAction("DashBoard", "Admin"));
                 }
                 else
                 {
                     return(RedirectToAction("Index", "Home"));
                 }
             }
         }
         else
         {
             ModelState.AddModelError("", "Invalid User");
         }
     }
     return(View());
 }
        public ActionResult AddOrEdit(int id = 0)
        {
            if (id == 0)
            {
                using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
                {
                    ViewBag.SubMenus = db.tblSubMenus.ToList();
                    ViewBag.Action   = "Create New Item";
                    return(View(new ItemViewModel()));
                }
            }
            else
            {
                using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
                {
                    ViewBag.Action = "Edit Item";
                    ViewBag.Menus  = db.tblSubMenus.ToList();
                    tblItem       item   = db.tblItems.Where(i => i.ItemId == id).FirstOrDefault();
                    ItemViewModel itemvm = new ItemViewModel();
                    itemvm.ItemId      = item.ItemId;
                    itemvm.SubMenuId   = Convert.ToInt32(item.SubMenuId);
                    itemvm.Title       = item.Title;
                    itemvm.Price       = item.Price;
                    itemvm.Description = item.Description;
                    itemvm.SmallImage  = item.SmallImage;
                    itemvm.LargeImage  = item.LargeImage;
                    //HttpPostedFileBase fup = Request.Files["SmallImage"];
                    //if(fup!=null)
                    //{
                    //    if(fup.FileName!="")
                    //    {
                    //        fup.SaveAs(Server.MapPath("~/img/dogaccessories" + fup.FileName));

                    //    }
                    //}

                    //HttpPostedFileBase fup1 = Request.Files["LargeImage"];
                    //if (fup1 != null)
                    //{
                    //    if (fup1.FileName != "")
                    //    {
                    //        fup1.SaveAs(Server.MapPath("~/img/dogaccessories" + fup1.FileName));
                    //        itemvm.LargeImage = item.LargeImage;
                    //    }
                    //}



                    itemvm.IsAvailable = "Available";

                    ViewBag.SubMenus = db.tblSubMenus.ToList();

                    return(View(itemvm));
                }
            }
        }
Exemplo n.º 3
0
 public ActionResult Delete(int id)
 {
     using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
     {
         tblOrder sm = db.tblOrders.Where(x => x.OrderId == id).FirstOrDefault();
         db.tblOrders.Remove(sm);
         db.SaveChanges();
         return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 4
0
        public ActionResult ViewOrder_Post(int id)
        {
            using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
            {
                tblOrder sm = db.tblOrders.Where(x => x.OrderId == id).FirstOrDefault();
                sm.DeliveredStatus = "Confirmed";



                db.SaveChanges();
                return(RedirectToAction("ManageOrder", "Order"));
            }
        }
Exemplo n.º 5
0
 public JsonResult GetData()
 {
     using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
     {
         db.Configuration.LazyLoadingEnabled = false;
         List <OrderViewModel> lstorder = new List <OrderViewModel>();
         var empList = db.tblOrders.Select(x => new { OrderId = x.OrderId, Firstname = x.Firstname, Lastname = x.Lastname, Address = x.Address, Phone = x.Phone, Total = x.Total, OrderDate = x.OrderDate, DeliveredStatus = x.DeliveredStatus }).ToList();
         foreach (var item in empList)
         {
             lstorder.Add(new OrderViewModel()
             {
                 OrderId = item.OrderId, Firstname = item.Firstname, Lastname = item.Lastname, Address = item.Address, Phone = item.Phone, Total = item.Total.ToString(), OrderDate = item.OrderDate.ToString(), DeliveredStatus = item.DeliveredStatus
             });
         }
         return(Json(new { data = lstorder }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 6
0
 public JsonResult GetData()
 {
     using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
     {
         db.Configuration.LazyLoadingEnabled = false;
         List <UserViewModel> lstitem = new List <UserViewModel>();
         var lst = db.tblUsers.ToList();
         foreach (var item in lst)
         {
             lstitem.Add(new UserViewModel()
             {
                 UserId = item.UserId, Username = item.Username, Photo = item.Photo
             });
         }
         return(Json(new { data = lstitem }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 7
0
 public JsonResult GetData()
 {
     using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
     {
         db.Configuration.LazyLoadingEnabled = false;
         List <SubMenuViewModel> lst = new List <SubMenuViewModel>();
         var empList = db.tblSubMenus.Select(x => new { SubMenuId = x.SubMenuId, SubMenuName = x.SubMenuName }).ToList();
         foreach (var item in empList)
         {
             lst.Add(new SubMenuViewModel()
             {
                 SubMenuId = item.SubMenuId, SubMenuName = item.SubMenuName
             });
         }
         return(Json(new { data = lst }, JsonRequestBehavior.AllowGet));
     }
 }
 public JsonResult GetData()
 {
     using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
     {
         db.Configuration.LazyLoadingEnabled = false;
         List <ItemViewModel> lstitem = new List <ItemViewModel>();
         var lst = db.tblItems.ToList();
         foreach (var item in lst)
         {
             lstitem.Add(new ItemViewModel()
             {
                 ItemId = item.ItemId, Title = item.Title, Price = item.Price, Description = item.Description, SmallImage = item.SmallImage, LargeImage = item.LargeImage, IsAvailable = item.IsAvailable
             });
         }
         return(Json(new { data = lstitem }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 9
0
 public ActionResult ViewOrder(int id)
 {
     using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
     {
         List <OrderDetailsViewModel> lstod = new List <OrderDetailsViewModel>();
         var empList = db.tblOrderDetails.Where(x => x.OrderId == id).ToList();
         foreach (tblOrderDetail item in empList)
         {
             lstod.Add(new OrderDetailsViewModel()
             {
                 ItemId = Convert.ToInt32(item.ItemId), ItemName = item.tblItem.Title, Quantity = Convert.ToInt32(item.Quantity), UnitPrice = Convert.ToDecimal(item.UnitPrice)
             });
         }
         Session.Add("itemlist", lstod);
         Session.Add("orderid", id);
         return(View(lstod));
     }
 }
Exemplo n.º 10
0
 public ActionResult AddOrEdit(tblSubMenu sm)
 {
     using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
     {
         if (sm.SubMenuId == 0)
         {
             db.tblSubMenus.Add(sm);
             db.SaveChanges();
             return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             db.Entry(sm).State = EntityState.Modified;
             db.SaveChanges();
             return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }
Exemplo n.º 11
0
 public ActionResult AddOrEdit(int id = 0)
 {
     if (id == 0)
     {
         using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
         {
             // ViewBag.Menus = db.tblMenus.ToList();
             return(View(new tblSubMenu()));
         }
     }
     else
     {
         using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
         {
             // ViewBag.Menus = db.tblMenus.ToList();
             return(View(db.tblSubMenus.Where(x => x.SubMenuId == id).FirstOrDefault()));
         }
     }
 }
Exemplo n.º 12
0
 public ActionResult AddOrEdit(SubMenuViewModel sm)
 {
     using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
     {
         if (sm.SubMenuId == 0)
         {
             tblSubMenu tb = new tblSubMenu();
             tb.SubMenuName = sm.SubMenuName;
             db.tblSubMenus.Add(tb);
             db.SaveChanges();
             return(Json(new { success = true, message = "Saved Successfully" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             tblSubMenu tbm = db.tblSubMenus.Where(m => m.SubMenuId == sm.SubMenuId).FirstOrDefault();
             tbm.SubMenuName = sm.SubMenuName;
             db.SaveChanges();
             return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
         }
     }
 }
Exemplo n.º 13
0
 public ActionResult AddOrEdit(int id = 0)
 {
     if (id == 0)
     {
         using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
         {
             return(View(new SubMenuViewModel()));
         }
     }
     else
     {
         using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
         {
             SubMenuViewModel sub = new SubMenuViewModel();
             var menu             = db.tblSubMenus.Where(x => x.SubMenuId == id).FirstOrDefault();
             sub.SubMenuId   = menu.SubMenuId;
             sub.SubMenuName = menu.SubMenuName;
             return(View(sub));
         }
     }
 }
        public ActionResult AddOrEdit(ItemViewModel ivm)
        {
            using (OnlineFoodDBEntities db = new OnlineFoodDBEntities())
            {
                if (ivm.ItemId == 0)
                {
                    tblItem itm = new tblItem();

                    itm.SubMenuId   = Convert.ToInt32(ivm.SubMenuId);
                    itm.Title       = ivm.Title;
                    itm.Price       = ivm.Price;
                    itm.Description = ivm.Description;
                    HttpPostedFileBase fup = Request.Files["SmallImage"];
                    if (fup != null)
                    {
                        if (fup.FileName != "")
                        {
                            fup.SaveAs(Server.MapPath("~/images/ItemImages/" + fup.FileName));
                            itm.SmallImage = fup.FileName;
                        }
                    }

                    HttpPostedFileBase fup1 = Request.Files["LargeImage"];
                    if (fup1 != null)
                    {
                        if (fup1.FileName != "")
                        {
                            fup1.SaveAs(Server.MapPath("~/images/ItemImages/" + fup1.FileName));
                            itm.LargeImage = fup1.FileName;
                        }
                    }
                    itm.IsAvailable = "Available";
                    db.tblItems.Add(itm);
                    db.SaveChanges();
                    ViewBag.Message = "Updated Successfully";
                }
                else
                {
                    tblItem itm = db.tblItems.Where(i => i.ItemId == ivm.ItemId).FirstOrDefault();
                    itm.SubMenuId   = Convert.ToInt32(ivm.SubMenuId);
                    itm.Title       = ivm.Title;
                    itm.Price       = ivm.Price;
                    itm.Description = ivm.Description;
                    HttpPostedFileBase fup = Request.Files["SmallImage"];
                    if (fup != null)
                    {
                        if (fup.FileName != "")
                        {
                            fup.SaveAs(Server.MapPath("~/images/ItemImages/" + fup.FileName));
                            itm.SmallImage = fup.FileName;
                        }
                    }

                    HttpPostedFileBase fup1 = Request.Files["LargeImage"];
                    if (fup1 != null)
                    {
                        if (fup1.FileName != "")
                        {
                            fup1.SaveAs(Server.MapPath("~/images/ItemImages/" + fup1.FileName));
                            itm.LargeImage = fup1.FileName;
                        }
                    }


                    db.SaveChanges();
                    ViewBag.Message = "Updated Successfully";
                }
                ViewBag.SubMenus = db.tblSubMenus.ToList();
                return(View(new ItemViewModel()));
            }
        }