コード例 #1
0
 public ActionResult EditDepartment([Bind(Include = "DepartmentId,Name,DateOfAdding,DateInfoChanging")] Department department)
 {
     if (ModelState.IsValid)
     {
         db.Entry(department).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("ShowDepartments"));
     }
     return(View(department));
 }
コード例 #2
0
        public async Task <IHttpActionResult> PutDepartment(int id, Department department)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != department.DepartmentID)
            {
                return(BadRequest());
            }

            db.Entry(department).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DepartmentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public async Task <IActionResult> PutEmployee(int id, Employee employee)
        {
            if (id != employee.Id)
            {
                return(BadRequest());
            }

            _context.Entry(employee).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #4
0
        public async Task <IActionResult> PutDepartment(int id, Department department)
        {
            if (id != department.Id)
            {
                return(BadRequest());
            }

            _context.Entry(department).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DepartmentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #5
0
        public async Task <IActionResult> PutWorker(int id, Worker worker)
        {
            if (id != worker.WorkerId)
            {
                return(BadRequest());
            }

            _context.Entry(worker).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WorkerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #6
0
        public async Task <IHttpActionResult> PutEmployees(int id, Employees employees)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employees.EmployeeID)
            {
                return(BadRequest());
            }

            db.Entry(employees).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #7
0
        public PartialViewResult UpdateEmployee(Employee employee)
        {
            db.Entry(employee).State = EntityState.Modified;
            db.SaveChanges();
            var departments = db.Departments;

            return(PartialView("_PartialIndex", departments));
        }
コード例 #8
0
 public ActionResult Edit([Bind(Include = "DepartmentsId,DepartmentName")] Departments departments)
 {
     if (ModelState.IsValid)
     {
         db.Entry(departments).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(departments));
 }
コード例 #9
0
 public ActionResult Edit([Bind(Include = "JobId,JobName,Salary")] Job job)
 {
     if (ModelState.IsValid)
     {
         db.Entry(job).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(job));
 }
コード例 #10
0
 public ActionResult UpdateEmployee(Employee employee)
 {
     if (employee == null)
     {
         return(HttpNotFound());
     }
     db.Entry(employee).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index", "Department"));
 }
コード例 #11
0
 public ActionResult Edit([Bind(Include = "PersonId,Name,BeginDate,Grad,sex,Tecnology,Prim")] Person person)
 {
     if (ModelState.IsValid)
     {
         db.Entry(person).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(person));
 }
コード例 #12
0
 public ActionResult Edit([Bind(Include = "Id,EmpName,Designation,DepartmentId")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DepartmentName", employee.DepartmentId);
     return(View(employee));
 }
コード例 #13
0
        public async Task <IActionResult> PutMeetings(int id, Meeting meeting)
        {
            if (id != meeting.Id)
            {
                return(BadRequest());
            }

            db.Entry(meeting).State = EntityState.Modified;
            await db.SaveChangesAsync();

            return(NoContent());
        }
コード例 #14
0
        public async Task <IActionResult> PutEmployees(int id, Employee employee)
        {
            if (id != employee.Id)
            {
                return(BadRequest());
            }

            db.Entry(employee).State = EntityState.Modified;
            await db.SaveChangesAsync();

            return(NoContent());
        }
コード例 #15
0
 public ActionResult Edit(int id, EmployeeModel emp)
 {
     try
     {
         // TODO: Add update logic here
         DbContext.Entry(emp).State = System.Data.Entity.EntityState.Modified;
         DbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
コード例 #16
0
        public async Task <bool> Put(int Id, Employee department)
        {
            _context.Entry(department).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(false);
            }
            return(true);
        }
コード例 #17
0
 public bool Update(Department entity)
 {
     try
     {
         context.Entry(entity).State = EntityState.Modified;
         int result = context.SaveChanges();
         if (result > 0)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         //log
         throw ex;
     }
 }
コード例 #18
0
ファイル: EmployeesRepository.cs プロジェクト: WssIDs/CompIP
 public void Update(Employee t)
 {
     context.Entry <Employee>(t).State = EntityState.Modified;
 }
コード例 #19
0
ファイル: ComputersRepository.cs プロジェクト: WssIDs/CompIP
 public void Update(Computer t)
 {
     context.Entry <Computer>(t).State = EntityState.Modified;
 }
コード例 #20
0
 public void Update(Organization t)
 {
     context.Entry <Organization>(t).State = EntityState.Modified;
 }