public async Task<IActionResult> Get(int employeeId, int positionId) { var ep = await _employeePositionLogic.Find(employeeId, positionId); if (ep == null) return NotFound($"Ne postoji zaposleni sa rednim brojem:{employeeId} koji je radio na poziciji sa rednim brojem:{positionId}"); EmployeePositionDTO empPosReturn = _mapper.Map<EmployeePositionDTO>(ep); return Ok(empPosReturn); }
public EmployeePositionDTO newEmployeePosition(EmployeePositionDTO employeePosition) { var added = MapperFactory.CurrentMapper.Map <EmployeePosition>(employeePosition); added = uow.GetRepository <EmployeePosition>().Add(added); uow.SaveChanges(); return(MapperFactory.CurrentMapper.Map <EmployeePositionDTO>(added)); }
public EmployeePositionDTO updateEmployeePosition(EmployeePositionDTO employeePosition) { var selectedEmployeePosition = uow.GetRepository <EmployeePosition>().Get(z => z.Id == employeePosition.Id); selectedEmployeePosition = MapperFactory.CurrentMapper.Map(employeePosition, selectedEmployeePosition); uow.GetRepository <EmployeePosition>().Update(selectedEmployeePosition); uow.SaveChanges(); return(MapperFactory.CurrentMapper.Map <EmployeePositionDTO>(selectedEmployeePosition)); }
public async Task <ActionResult> Edit(EmployeePositionDTO vm) { if (ModelState.IsValid) { var employeePosition = await FindAsyncEmployeePosition(vm.Id); if (employeePosition.AppDefault) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } employeePosition.Position = vm.Position; await DataContext.SaveChangesAsync(this); return(RedirectToAction("Index")); } return(View(vm)); }