Ejemplo n.º 1
0
        public bool Update(kyghi entity, int id)
        {
            try
            {
                var ghi = db.kyghis.Find(id);
                ghi.nv_id = entity.nv_id;

                ghi.k_ten        = entity.k_ten;
                ghi.k_ngaybatdau = entity.k_ngaybatdau;


                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                //logging
                return(false);
            }
        }
        public ActionResult Create(kyghi collection)
        {
            if (ModelState.IsValid)
            {
                var dao = new KyGhiDao();



                long id = dao.Insert(collection);
                if (id > 0)
                {
                    return(RedirectToAction("Index", "KyGhi"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm Kì Ghi không thành công");
                }
            }
            return(View("Index"));
        }
        public ActionResult Edit(kyghi collection, int id)
        {
            if (ModelState.IsValid)
            {
                var dao = new KyGhiDao();



                var result = dao.Update(collection, id);
                if (result)
                {
                    return(RedirectToAction("Index", "KyGhi"));
                }
                else
                {
                    ModelState.AddModelError("", "Cập nhật không thành công");
                }
            }
            return(View("Index"));
        }
Ejemplo n.º 4
0
 public long Insert(kyghi entity)
 {
     db.kyghis.Add(entity);
     db.SaveChanges();
     return(entity.k_id);
 }
        public ActionResult Delete(int id, kyghi collection)
        {
            new KyGhiDao().Delete(id);

            return(RedirectToAction("Index", "KyGhi"));
        }