Ejemplo n.º 1
0
        public EmployeeSalaryDTO newSalary(EmployeeSalaryDTO employeeSalary)
        {
            var added = MapperFactory.CurrentMapper.Map <EmployeeSalary>(employeeSalary);

            added = uow.GetRepository <EmployeeSalary>().Add(added);
            uow.SaveChanges();
            return(MapperFactory.CurrentMapper.Map <EmployeeSalaryDTO>(added));
        }
Ejemplo n.º 2
0
        public EmployeeSalaryDTO updateEmployeeSalary(EmployeeSalaryDTO employeeSalary)
        {
            var selectedEmployeeSalary = uow.GetRepository <EmployeeSalary>().Get(z => z.Id == employeeSalary.Id);

            selectedEmployeeSalary = MapperFactory.CurrentMapper.Map(employeeSalary, selectedEmployeeSalary);
            uow.GetRepository <EmployeeSalary>().Update(selectedEmployeeSalary);
            uow.SaveChanges();
            return(MapperFactory.CurrentMapper.Map <EmployeeSalaryDTO>(selectedEmployeeSalary));
        }
Ejemplo n.º 3
0
        public HttpResponseMessage Get(int Id)
        {
            EmployeeSalaryDTO selectedTitle = service.getEmployeeSalary(Id);

            if (selectedTitle == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Id + sysLanguage.CompanyTitlesControllerStrings.id_title));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, selectedTitle));
        }
Ejemplo n.º 4
0
 public EmployeeSalaryDTO newEmployeeSalary(EmployeeSalaryDTO employeeSalary)
 {
     if (!uow.GetRepository <EmployeeSalary>().GetAll().Any(z => z.Id == employeeSalary.Id))
     {
         var adedEmployeeSalary = MapperFactory.CurrentMapper.Map <EmployeeSalary>(employeeSalary);
         adedEmployeeSalary = uow.GetRepository <EmployeeSalary>().Add(adedEmployeeSalary);
         uow.SaveChanges();
         return(MapperFactory.CurrentMapper.Map <EmployeeSalaryDTO>(adedEmployeeSalary));
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 5
0
 public HttpResponseMessage Put(EmployeeSalaryDTO accessTypeDTO)
 {
     try
     {
         EmployeeSalaryDTO dto = service.updateEmployeeSalary(accessTypeDTO);
         if (dto != null)
         {
             return(Request.CreateResponse(HttpStatusCode.OK, dto));
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyTitlesControllerStrings.update_title));
         }
     }
     catch (Exception)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyTitlesControllerStrings.update_title));
     }
 }
Ejemplo n.º 6
0
 public HttpResponseMessage Post(EmployeeSalaryDTO accessTypeDTO)
 {
     try
     {
         EmployeeSalaryDTO dto = service.newEmployeeSalary(accessTypeDTO);
         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));
         }
     }
     catch (Exception)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.SeeOther, sysLanguage.CompanyTitlesControllerStrings.add_title));
     }
 }