Example #1
0
        public ActionResult Prd_detail(string tendh)
        {
            dongho product = DAO_product.getByName(tendh).First();

            product.dongia *= 1000;
            return(View(product));
        }
Example #2
0
        public ActionResult Delete_Product(string tendh, string url)
        {
            dongho check_dh = DAO_product.getByName(tendh).First();

            if (check_dh != null)
            {
                DAO_product.delete(check_dh);
            }
            return(Redirect(url));
        }
Example #3
0
        public ActionResult Edit(int id, dongho dongho)
        {
            if (ModelState.IsValid)
            {
                var dao = new DongHoDao();



                var result = dao.Update(dongho, id);
                if (result)
                {
                    return(RedirectToAction("Index", "DongHo"));
                }
                else
                {
                    ModelState.AddModelError("", "Cập nhật user không thành công");
                }
            }
            return(View("Index"));
        }
Example #4
0
        public ActionResult Create(dongho entity)
        {
            if (ModelState.IsValid)
            {
                var dao = new DongHoDao();



                long id = dao.Insert(entity);
                if (id > 0)
                {
                    return(RedirectToAction("Index", "DongHo"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm không thành công");
                }
            }
            return(View("Index"));
        }
Example #5
0
        public bool Update(dongho entity, int id)
        {
            try
            {
                var dongho = db.donghoes.Find(id);

                dongho.kh_id           = entity.kh_id;
                dongho.dh_thuonghieu   = entity.dh_thuonghieu;
                dongho.dh_maso         = entity.dh_maso;
                dongho.dh_ngaykiemdinh = entity.dh_ngaykiemdinh;
                dongho.dh_ngaylap      = entity.dh_ngaylap;


                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                //logging
                return(false);
            }
        }
Example #6
0
 public long Insert(dongho entity)
 {
     db.donghoes.Add(entity);
     db.SaveChanges();
     return(entity.dh_id);
 }
Example #7
0
 public ActionResult Edit_Prd(dongho dh, string url)
 {
     DAO_product.update(dh);
     return(Redirect(url));
 }