public void AddEmployee(EmployeeBLLModel model) { var efModel = new Employee() { Name = model.Name, Salary = model.Salary, IsRetired = model.IsRetired }; context.Employees.Add(efModel); context.SaveChanges(); }
public void Add(EmployeeBLLModel model) { //var checkResults = CheckForDuplicates(model); //if (checkResults.Any()) //{ // result.Errors = checkResults; //} //else //{ _dataAccessService.AddEmployee(model); //} }
public ActionResult AddEmployee(EmployeeViewModel model) { if (ModelState.IsValid) { //add to business layer var emplyeeBModel = new EmployeeBLLModel(); emplyeeBModel.Name = model.Name; emplyeeBModel.Salary = model.Salary; emplyeeBModel.IsRetired = model.IsRetired; _employeeService.Add(emplyeeBModel); return(RedirectToAction("EmployeeList")); } return(View(model)); }
public EmployeeBLLModel FetchById(long id) { var result = new EmployeeBLLModel(); //try //{ // result = _dataAccessService.f.FetchEmployee(id); //} //catch (Exception e) //{ // // //} return(result); }
private List <string> CheckForDuplicates(EmployeeBLLModel model) { var errors = new List <string>(); var duplicateModel = _dataAccessService.FetchAllEmployee() .FirstOrDefault(x => (x.Name.Equals(model.Name, StringComparison.CurrentCultureIgnoreCase)) && x.EmployeeId != model.EmployeeId); if (duplicateModel != null) { errors.Add(duplicateModel.Name.Equals(model.Name, StringComparison.OrdinalIgnoreCase) ? "Errors.EmployeeNameExists" : "Errors.EmployeeCodeExists"); } return(errors); }
public void Update(EmployeeBLLModel model) { try { //var checkResults = CheckForDuplicates(model); //if (checkResults.Any()) //{ // result.Errors = checkResults; //} //else //{ _dataAccessService.UpdateEmployee(model); //} } catch (Exception e) { // result.Errors.Add(e.BuildExceptionMessage()); } }
public void UpdateEmployee(EmployeeBLLModel model) { throw new NotImplementedException(); }