コード例 #1
0
        public ActionResult Edit([Bind(Include = "Id,UserId,TeamId,PositionId,FirstName,LastName,HireDate")] Employee employee)
        {
            var hireDate = Request["HireDate1"];

            employee.HireDate = CalculateDate.StringToDate(hireDate, ".", "/", "-");

            IViewBagLoader viewBagLoader = new EmployeeEditViewBagLoader();

            viewBagLoader.Load(this, _db);

            if (ModelState.IsValid)
            {
                _db.Entry(employee).State = EntityState.Modified;
                _db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(employee));
        }
コード例 #2
0
        // GET: HREmployees/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Employee employee = _db.T_Employees.Find(id);

            if (employee == null)
            {
                return(HttpNotFound());
            }

            IViewBagLoader viewBagLoader = new EmployeeEditViewBagLoader();

            viewBagLoader.Load(this, _db);

            return(View(employee));
        }