Exemplo n.º 1
0
        public ActionResult Edit(EmployeeInputModel inputModel)
        {
            var employee = _employeeRepository.FindEmployeeById("1", inputModel.OriginalSerial);
            if (employee == null)
            {
                return new HttpNotFoundResult();
            }

            if (inputModel.OriginalSerial != inputModel.Serial1)
            {
                _employeeUnitOfWork.Initialize();
                _employeeUnitOfWork.Delete(employee);
                _employeeUnitOfWork.Execute();

                employee = new Employee();
                employee.CompanyId = "1";
            }

            employee.SerialNumber = inputModel.Serial1;
            employee.FirstName = inputModel.FirstName;
            employee.LastName = inputModel.LastName;

            _employeeUnitOfWork.Initialize();
            _employeeUnitOfWork.InsertOrReplace(employee);
            _employeeUnitOfWork.Execute();

            return RedirectToAction("Index");
        }
Exemplo n.º 2
0
        public ActionResult Create(EmployeeInputModel inputModel)
        {
            var newEmployee = new Employee();
            newEmployee.CompanyId = "1";
            newEmployee.SerialNumber = inputModel.Serial1;
            newEmployee.FirstName = inputModel.FirstName;
            newEmployee.LastName = inputModel.LastName;

            _employeeUnitOfWork.Initialize();
            _employeeUnitOfWork.Insert(newEmployee);
            _employeeUnitOfWork.Execute();

            return RedirectToAction("Index");
        }