コード例 #1
0
 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);
 }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }