Exemplo n.º 1
0
        public Employee Update(Employee entity)
        {
            Employee employee = context.Employees.Find(entity.Id);
            context.Entry(employee).CurrentValues.SetValues(entity);
            context.Entry(employee).State = EntityState.Modified;
            context.SaveChanges();

            return employee;
        }
Exemplo n.º 2
0
        public ActionResult Create(Employee employee)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var createdEmployee = employeeRepository.Create(employee);
                    // Bootstrap Alert
                    return RedirectToAction("Index");
                }
                catch (Exception ex)
                {
                    // Handle
                }
            }

            ViewBag.Teams = new SelectList(teamRepository.GetAll(), "Id", "Name");
            return View(employee);
        }
Exemplo n.º 3
0
 public Employee Update(Employee entity)
 {
     session.SaveOrUpdate(entity);
     var employee = session.Get<Employee>(entity.Id);
     return employee;
 }
Exemplo n.º 4
0
 public Employee Create(Employee entity)
 {
     var employeeId = session.Save(entity);
     Employee employee = session.Get<Employee>(employeeId);
     return employee;
 }
Exemplo n.º 5
0
 public Employee Create(Employee entity)
 {
     Employee employee = context.Employees.Add(entity);
     context.SaveChanges();
     return employee;
 }