public ActionResult Create(ChucVu chucVu) { if (ModelState.IsValid) { database.Add(chucVu); database.SaveChanges(); return(RedirectToAction("Index")); } return(View(chucVu)); }
public ActionResult Create(PhongBan phongBan) { if (ModelState.IsValid) { database.Add(phongBan); database.SaveChanges(); return(RedirectToAction("Index")); } return(View(phongBan)); }
public ActionResult Create(LoaiKhenThuong loaiKhenThuong) { if (ModelState.IsValid) { database.Add(loaiKhenThuong); database.SaveChanges(); return(RedirectToAction("Index", "DanhGia")); } return(View(loaiKhenThuong)); }
public ActionResult Delete(int id, KhenThuong khenThuong) { khenThuong = database.KhenThuongs.Where(x => x.Idkt == id).FirstOrDefault(); database.Remove(khenThuong); database.SaveChanges(); return(RedirectToAction("Index")); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { // Stores the Request in an Accessible object var request = filterContext.HttpContext.Request; // Generate an audit Audit audit = new Audit() { // Your Audit Identifier AuditID = Guid.NewGuid(), // Our Username (if available) UserName = (request.IsAuthenticated) ? filterContext.HttpContext.User.Identity.Name : "Anonymous", // The IP Address of the Request IPAddress = request.ServerVariables["HTTP_X_FORWARDED_FOR"] ?? request.UserHostAddress, // The URL that was accessed URLAccessed = request.RawUrl, // Creates our Timestamp TimeAccessed = DateTime.UtcNow, Data = SerializeRequest(request) }; // Stores the Audit in the Database QLNSContext context = new QLNSContext(); context.Audit.Add(audit); context.SaveChanges(); // Finishes executing the Action as normal base.OnActionExecuting(filterContext); }
public ActionResult Delete(int id, KyLuat kyLuat) { kyLuat = database.KyLuats.Where(x => x.Idkl == id).FirstOrDefault(); database.Remove(kyLuat); database.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Delete(int id, NhanVien nhanVien) { nhanVien = database.NhanViens.Where(x => x.Idnv == id).FirstOrDefault(); database.Remove(nhanVien); database.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(HopDongLaoDong hopDongLaoDong) { var model = new ViewModelNV(); model.ListNhanVien = database.NhanViens.ToArray(); //model.hopDongLaoDong = database.HopDongLaoDongs.Where(x => x.Idnv == id).FirstOrDefault(); if (ModelState.IsValid) { database.Update(hopDongLaoDong); database.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
public static void Init(QLNSContext context) { var DanTocGroup = context.DM_NhomDanhmuc.Where(x => x.GroupCode == DanhMucConstantBase.DanToc).FirstOrDefault(); if (DanTocGroup == null) { context.DM_NhomDanhmuc.Add(new DM_NhomDanhmuc() { GroupCode = DanhMucConstantBase.DanToc, GroupName = DanhMucConstantBase.DanToc }); context.SaveChanges(); } }
public IActionResult Post([FromBody] Accounts value) { _context.Accounts.Add(value); _context.SaveChanges(); return(StatusCode(201, value)); }