Пример #1
0
 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));
 }
Пример #2
0
 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));
 }
Пример #3
0
        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));
        }
Пример #4
0
        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));
        }
Пример #5
0
 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));
 }
Пример #6
0
        /// <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");
            }
        }