public ActionResult Edit([Bind(Include = "Id,Name,Description,ActiveStatus")] Role role) { if (ModelState.IsValid) { db.Entry(role).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(role)); }
public ActionResult Edit([Bind(Include = "Id,loginId,Password,ActiveStatus")] User user) { if (ModelState.IsValid) { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public ActionResult Create([Bind(Include = "Id,EmpCode,FullName,NickName,DesignationId,DeptId,Phone,Email,Address")] Employee employee) { if (ModelState.IsValid) { employee.ActionDate = DateTime.Now; if (employee.Id != 0) { db.Entry(employee).State = EntityState.Modified; } else { db.Employees.Add(employee); } db.SaveChanges(); return(RedirectToAction("Create")); } ViewBag.DeptId = new SelectList(db.Depts, "Id", "Name", employee.DeptId); ViewBag.DesignationId = new SelectList(db.Designations, "Id", "Name", employee.DesignationId); return(View(employee)); }
public ActionResult Create(Employee employee) { if (ModelState.IsValid) { employee.ActionDate = DateTime.Now; if (employee.Id != 0) { db.Entry(employee).State = EntityState.Modified; } else { db.Employees.Add(employee); } db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.DeptId = new SelectList(db.Depts, "DeptId", "Name", employee.DeptId); ViewBag.DesignationId = new SelectList(db.Designations, "Id", "Name", employee.DesignationId); return(View(employee)); }
public IActionResult Edit(Dept dept) { if (ModelState.IsValid) { _context.Entry(dept).State = EntityState.Modified; _context.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.DeptId = new SelectList(db.Depts, "Id", "Name", employee.DeptId); //ViewBag.DesignationId = new SelectList(db.Designations, "Id", "Name", employee.DesignationId); return(View(dept)); }
/// <summary> /// Chỉnh sửa 1 bản ghi theo id và thôgn tin mới /// </summary> /// <typeparam name="T1"></typeparam> /// <param name="id"></param> /// <param name="tEntity"></param> /// <returns></returns> public async Task <ActionResult <bool> > ChangeAnEntityByID <T1>(Guid id, T1 tEntity) where T1 : class { using (HRMContext context = new HRMContext()) { //Tim xem idz` context.Entry(tEntity).State = EntityState.Modified; var res = await context.SaveChangesAsync(); if (res < 1) { return(false); } return(true); //return new ActionServiceResult((int)HttpStatusCode.OK, true, "Cập nhật thành công"); } }