public int AddEmployee(NewEmployeeVm employee) { var emp = _mapper.Map <Employee>(employee); var id = _employeeRepo.AddEmployee(emp); return(id); }
public NewEmployeeVm SetParametersToVm(NewEmployeeVm model) { model.EmployeeTypes = GetEmployeeTypes().ToList(); model.EngineTypes = GetEngineTypes().ToList(); model.ContactDetailTypes = GetConactDetailTypes().ToList(); return(model); }
public IActionResult EditEmployee(NewEmployeeVm empVm) { if (!ModelState.IsValid) { _empService.SetParametersToVm(empVm); return(View(empVm.Id)); } _empService.UpdateEmployee(empVm); return(RedirectToAction("ViewEmployee")); }
public IActionResult AddEmployee(NewEmployeeVm model) { if (!ModelState.IsValid) { _empService.SetParametersToVm(model); return(View(model)); } model.Vehicles = _empService.CheckVehiclesList(model.Vehicles); model.ContactDetails = _empService.CheckContactsList(model.ContactDetails); var id = _empService.AddEmployee(model); _logger.LogInformation("New employee has been added - " + id); return(RedirectToAction("ViewEmployee")); }
public IActionResult AddEmployee() { var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; if (!_empService.CheckIfEmployeeExist(userId)) { return(RedirectToAction("ViewEmployee")); } var model = new NewEmployeeVm() { UserId = User.FindFirst(ClaimTypes.NameIdentifier).Value }; _empService.SetParametersToVm(model); return(View(model)); }
public void UpdateEmployee(NewEmployeeVm empVm) { var emp = _mapper.Map <Employee>(empVm); _employeeRepo.UpdateEmployee(emp); }