示例#1
0
        public AdvanceDTO updateAdvance(AdvanceDTO advance)
        {
            var selectedAdvance = uow.GetRepository <Advance>().Get(z => z.Id == advance.Id);

            selectedAdvance = MapperFactory.CurrentMapper.Map(advance, selectedAdvance);
            uow.GetRepository <Advance>().Update(selectedAdvance);
            uow.SaveChanges();
            return(MapperFactory.CurrentMapper.Map <AdvanceDTO>(selectedAdvance));
        }
        public HttpResponseMessage Get(int Id)
        {
            AdvanceDTO selectedTitle = service.getAdvance(Id);

            if (selectedTitle == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Id + sysLanguage.CompanyTitlesControllerStrings.id_title));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, selectedTitle));
        }
        public HttpResponseMessage Put(AdvanceDTO advanceDTO)
        {
            AdvanceDTO dto = service.updateAdvance(advanceDTO);

            if (dto != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, dto));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyTitlesControllerStrings.update_title));
            }
        }
示例#4
0
 public AdvanceDTO newAdvance(AdvanceDTO advance)
 {
     if (!uow.GetRepository <Advance>().GetAll().Any(z => z.Id == advance.Id))
     {
         var adedAdvance = MapperFactory.CurrentMapper.Map <Advance>(advance);
         adedAdvance = uow.GetRepository <Advance>().Add(adedAdvance);
         uow.SaveChanges();
         return(MapperFactory.CurrentMapper.Map <AdvanceDTO>(adedAdvance));
     }
     else
     {
         return(null);
     }
 }
        public HttpResponseMessage Post(AdvanceDTO advanceDTO)
        {
            AdvanceDTO dto = service.newAdvance(advanceDTO);

            if (dto != null)
            {
                HttpResponseMessage message = Request.CreateResponse(HttpStatusCode.Created, dto);
                message.Headers.Location = new Uri(Request.RequestUri + "/" + dto.Id);
                return(message);
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyTitlesControllerStrings.add_title));
            }
        }
示例#6
0
        public AdvanceDTO newAdvance(AdvanceDTO advance)
        {
            var addedAdvance = MapperFactory.CurrentMapper.Map <Advance>(advance);

            uow.GetRepository <Advance>().Add(addedAdvance);
            uow.SaveChanges();
            var addedEmployeeAdvance = new EmployeeAdvance()
            {
                EmployeeId = advance.EmployeeId,
                AdvanceId  = addedAdvance.Id
            };

            uow.GetRepository <EmployeeAdvance>().Add(addedEmployeeAdvance);
            uow.SaveChanges();
            return(MapperFactory.CurrentMapper.Map <AdvanceDTO>(addedAdvance));
        }
        public IActionResult AddAdvance(AdvanceDTO advanceDTO)
        {
            EmployeeDTO emp;

            if (advanceDTO.EmployeeId == 0)
            {
                emp = employeeService.getEmployeeUser(CurrentUser.Id);
                advanceDTO.EmployeeId = emp.Id;
            }
            else
            {
                emp = employeeService.getEmployeeInfo(advanceDTO.EmployeeId);
            }

            string Name = emp.Name;

            Name += " ";
            string LastName = emp.Surname;

            advanceDTO.EmployeeFullName = String.Concat(Name, LastName);
            advanceService.newAdvance(advanceDTO);
            return(RedirectToAction("Index", "Home"));
        }