public IHttpActionResult PutCN_CHI_TIET_NGHIEP_VU(int id, CN_CHI_TIET_NGHIEP_VU cN_CHI_TIET_NGHIEP_VU) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cN_CHI_TIET_NGHIEP_VU.ID) { return(BadRequest()); } db.Entry(cN_CHI_TIET_NGHIEP_VU).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CN_CHI_TIET_NGHIEP_VUExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetCN_CHI_TIET_NGHIEP_VU(int id) { CN_CHI_TIET_NGHIEP_VU cN_CHI_TIET_NGHIEP_VU = db.CN_CHI_TIET_NGHIEP_VU.Find(id); if (cN_CHI_TIET_NGHIEP_VU == null) { return(NotFound()); } return(Ok(cN_CHI_TIET_NGHIEP_VU)); }
public void PutCN_CHI_TIET_NGHIEP_VU(int id, CN_CHI_TIET_NGHIEP_VU chiTietNghiepVu) { var check = db.CN_CHI_TIET_NGHIEP_VU.Where(x => x.ID == id); if (check.Count() > 0) { var resultupdate = check.FirstOrDefault(); resultupdate.MO_TA = chiTietNghiepVu.MO_TA; db.SaveChanges(); } }
public IHttpActionResult PostCN_CHI_TIET_NGHIEP_VU(CN_CHI_TIET_NGHIEP_VU cN_CHI_TIET_NGHIEP_VU) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CN_CHI_TIET_NGHIEP_VU.Add(cN_CHI_TIET_NGHIEP_VU); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = cN_CHI_TIET_NGHIEP_VU.ID }, cN_CHI_TIET_NGHIEP_VU)); }
public IHttpActionResult DeleteCN_CHI_TIET_NGHIEP_VU(int id) { CN_CHI_TIET_NGHIEP_VU cN_CHI_TIET_NGHIEP_VU = db.CN_CHI_TIET_NGHIEP_VU.Find(id); if (cN_CHI_TIET_NGHIEP_VU == null) { return(NotFound()); } db.CN_CHI_TIET_NGHIEP_VU.Remove(cN_CHI_TIET_NGHIEP_VU); db.SaveChanges(); return(Ok(cN_CHI_TIET_NGHIEP_VU)); }
public ActionResult Capnhat_Nghiepvu() { ReflectionController rc = new ReflectionController(); List <Type> danhsach_loainghiepvu = rc.GetControllers("ERP.Web.Areas.HopLong.Controllers"); List <String> danhsach_nghiepvucu = db.CN_NGHIEP_VU.Select(c => c.ID).ToList(); List <String> danhsach_chitietnghiepvucu = db.CN_CHI_TIET_NGHIEP_VU.Select(p => p.TEN_CHI_TIET).ToList(); foreach (var c in danhsach_loainghiepvu) { if (!danhsach_nghiepvucu.Contains(c.Name)) { CN_NGHIEP_VU c_info = new CN_NGHIEP_VU() { ID = c.Name, TEN_NGHIEP_VU = c.Name, TRUC_THUOC = Session["MA_CONG_TY"].ToString() }; db.CN_NGHIEP_VU.Add(c_info); } List <String> danhsach_chitietnghiepvu = rc.GetActions(c); foreach (var p in danhsach_chitietnghiepvu) { if (!danhsach_chitietnghiepvucu.Contains(c.Name + "-" + p)) { CN_CHI_TIET_NGHIEP_VU permission = new CN_CHI_TIET_NGHIEP_VU() { TEN_CHI_TIET = c.Name + "-" + p, ID_NGHIEP_VU = c.Name, MO_TA = c.Name + "-" + p }; db.CN_CHI_TIET_NGHIEP_VU.Add(permission); } } } db.SaveChanges(); TempData["err"] = "<div class='alert alert-info' role='alert'><span class='glyphicon glyphicon-exclamation-sign' aria-hidden='true'></span><span class='sr-only'></span>Cập nhật thành công </div> "; return(RedirectToAction("Index")); }