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)); }
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)); }
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)); }
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); } }
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)); } }
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)); } }