Ejemplo n.º 1
0
        public ActionResult Edit(long cookerId)
        {
            ViewBag.danhSachGianHang = new VendorDao().ListAll();
            var cooker = new CookerDao().GetCookerById(cookerId);

            ViewBag.gian_hang = new VendorDao().GetVendorById(cooker.VendorId);
            return(View(cooker));
        }
Ejemplo n.º 2
0
        // GET: Admin/Cooker
        public ActionResult Index(long vendorId = 0)
        {
            ViewBag.gian_hang        = new VendorDao().GetVendorById(vendorId);
            ViewBag.tat_ca_gian_hang = new VendorDao().ListAllVendor();
            if (vendorId == 0)
            {
                var listcooker = new CookerDao().ListAllCooker();
                return(View(listcooker));
            }
            var model = new CookerDao().ListAllCookerByVendorId(vendorId);

            return(View(model));
        }
Ejemplo n.º 3
0
 public ActionResult Create(Cooker cooker)
 {
     ViewBag.danhSachDauBep = new VendorDao().ListAll();
     try
     {
         var result = new CookerDao().Insert(cooker);
         return(RedirectToAction("Index", "Cooker", new { vendorId = cooker.VendorId }));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message);
         return(View(cooker));
     }
 }
Ejemplo n.º 4
0
 public ActionResult EditStatus(long cookerId)
 {
     try
     {
         new CookerDao().UpdateStatus(cookerId);
         var VendorId = new CookerDao().GetCookerById(cookerId).VendorId;
         return(RedirectToAction("Index", "Cooker", new { vendorId = VendorId }));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message);
         var VendorId = new CookerDao().GetCookerById(cookerId).VendorId;
         return(RedirectToAction("Index", "Cooker", new { vendorId = VendorId }));
     }
 }
Ejemplo n.º 5
0
        public ActionResult Delete(long cookerId)
        {
            var VendorId = new CookerDao().GetCookerById(cookerId).VendorId;

            try
            {
                var result = new CookerDao().Delete(cookerId);
                return(RedirectToAction("Index", "Cooker", new { vendorId = VendorId }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(RedirectToAction("Index", "Cooker", new { vendorId = VendorId }));
            }
        }
Ejemplo n.º 6
0
 public ActionResult Edit(Cooker cooker)
 {
     try
     {
         var result   = new CookerDao().Update(cooker);
         var VendorId = new CookerDao().GetCookerById(cooker.ID).VendorId;
         return(RedirectToAction("Index", "Cooker", new { vendorId = VendorId }));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message);
         ViewBag.danhSachGianHang = new VendorDao().ListAll();
         ViewBag.gian_hang        = new VendorDao().GetVendorById(cooker.VendorId);
         return(View(cooker));
     }
 }
Ejemplo n.º 7
0
 public ActionResult Login(CookerLogin model)
 {
     if (ModelState.IsValid)
     {
         var dao    = new CookerDao();
         var result = dao.CookerLogin(model.UserName, model.Password);
         if (result == true)
         {
             var cooker        = dao.GetCookerByUserName(model.UserName);
             var cookerSession = new CookerLoginSession();
             cookerSession.UserName = cooker.UserName;
             cookerSession.VendorID = cooker.VendorId;
             Session.Add(Constant.COOKER_SESSION, cookerSession);
             return(RedirectToAction("Index", "TrangDauBep"));
         }
         else
         {
             ModelState.AddModelError("", "Sai tài khoản hoặc mật khẩu.");
         }
     }
     return(View(model));
 }