Exemplo n.º 1
0
        public int AddEmployee(NewEmployeeVm employee)
        {
            var emp = _mapper.Map <Employee>(employee);
            var id  = _employeeRepo.AddEmployee(emp);

            return(id);
        }
Exemplo n.º 2
0
 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));
        }
Exemplo n.º 6
0
        public void UpdateEmployee(NewEmployeeVm empVm)
        {
            var emp = _mapper.Map <Employee>(empVm);

            _employeeRepo.UpdateEmployee(emp);
        }