コード例 #1
0
ファイル: orderController.cs プロジェクト: pvdinh/cafe
 public ActionResult cartt(int id)
 {
     using (QuanLyCafeEntities3 dbb = new QuanLyCafeEntities3())
     {
         var x = dbb.billinfoes.ToList().Where(s => s.idfood == id).FirstOrDefault();
         if (x == null)
         {
             billinfo y = new billinfo();
             y.idbill = 1;
             y.idfood = id;
             y.count  = 1;
             dbb.billinfoes.Add(y);
             dbb.SaveChanges();
         }
         else
         {
             x.count++;
             dbb.SaveChanges();
         }
     }
     using (QuanLyCafeEntities3 dbb = new QuanLyCafeEntities3())
     {
         listfood.allbillinfos = dbb.billinfoes.ToList();
         listfood.allfoods     = new List <food>();
         foreach (billinfo item in listfood.allbillinfos)
         {
             var x = dbb.foods.ToList().Where(s => s.id == item.idfood).FirstOrDefault();
             listfood.allfoods.Add(x);
         }
     }
     //return PartialView("/views/shares/_cartproduct.cshtml", listfood);
     return(RedirectToAction("Index", "order", new { id = Session["id"] }));
 }
コード例 #2
0
        public ActionResult savestaff(staff sstaff)
        {
            using (QuanLyCafeEntities3 db = new QuanLyCafeEntities3())
            {
                var nv = db.staffs.Find(sstaff.idstaff);
                nv.name      = sstaff.name;
                nv.email     = sstaff.email;
                nv.position  = sstaff.position;
                nv.status    = sstaff.status;
                nv.idaccount = sstaff.idaccount;
                db.SaveChanges();
            }

            return(RedirectToAction("setting", "Home"));
        }
コード例 #3
0
ファイル: orderController.cs プロジェクト: pvdinh/cafe
        public ActionResult delproduct(int id)
        {
            using (QuanLyCafeEntities3 dbb = new QuanLyCafeEntities3())
            {
                billinfo x = new billinfo();
                x = dbb.billinfoes.ToList().Find(s => s.idfood == id);
                dbb.billinfoes.Remove(x);
                dbb.SaveChanges();
            }

            using (QuanLyCafeEntities3 dbb = new QuanLyCafeEntities3())
            {
                listfood.allbillinfos = dbb.billinfoes.ToList();
                listfood.allfoods     = new List <food>();
                foreach (billinfo item in listfood.allbillinfos)
                {
                    var x = dbb.foods.ToList().Where(s => s.id == item.idfood).FirstOrDefault();
                    listfood.allfoods.Add(x);
                }
            }

            return(PartialView("/views/shares/_cartproduct.cshtml", listfood));
        }