Example #1
0
        public EmploymentTypeDTO updateEmploymentType(EmploymentTypeDTO employmentType)
        {
            var selectedEmploymentType = uow.GetRepository <EmploymentType>().Get(z => z.Id == employmentType.Id);

            selectedEmploymentType = MapperFactory.CurrentMapper.Map(employmentType, selectedEmploymentType);
            uow.GetRepository <EmploymentType>().Update(selectedEmploymentType);
            uow.SaveChanges();
            return(MapperFactory.CurrentMapper.Map <EmploymentTypeDTO>(selectedEmploymentType));
        }
Example #2
0
        public HttpResponseMessage Get(int Id)
        {
            EmploymentTypeDTO selectedTitle = service.getEmploymentType(Id);

            if (selectedTitle == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Id + sysLanguage.CompanyTitlesControllerStrings.id_title));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, selectedTitle));
        }
Example #3
0
 public EmploymentTypeDTO newEmploymentType(EmploymentTypeDTO employmentType)
 {
     if (!uow.GetRepository <EmploymentType>().GetAll().Any(z => z.Id == employmentType.Id))
     {
         var adedEmploymentType = MapperFactory.CurrentMapper.Map <EmploymentType>(employmentType);
         adedEmploymentType = uow.GetRepository <EmploymentType>().Add(adedEmploymentType);
         uow.SaveChanges();
         return(MapperFactory.CurrentMapper.Map <EmploymentTypeDTO>(adedEmploymentType));
     }
     else
     {
         return(null);
     }
 }
Example #4
0
 public HttpResponseMessage Put(EmploymentTypeDTO accessTypeDTO)
 {
     try
     {
         EmploymentTypeDTO dto = service.updateEmploymentType(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));
     }
 }
Example #5
0
 public HttpResponseMessage Post(EmploymentTypeDTO accessTypeDTO)
 {
     try
     {
         EmploymentTypeDTO dto = service.newEmploymentType(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));
     }
 }
        public async Task <IActionResult> PutEmploymentType(int id, EmploymentTypeDTO employmentType)
        {
            if (id != employmentType.Id)
            {
                return(Conflict(new RespStatus {
                    Status = "Failure", Message = "Id is invalid"
                }));
            }


            var empTypes = await _context.EmploymentTypes.FindAsync(id);

            empTypes.EmpJobTypeDesc = employmentType.EmpJobTypeDesc;

            _context.EmploymentTypes.Update(empTypes);

            //_context.Entry(employmentType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmploymentTypeExists(id))
                {
                    return(Conflict(new RespStatus {
                        Status = "Failure", Message = "Employment Type Id invalid!"
                    }));
                }
                else
                {
                    throw;
                }
            }

            return(Ok(new RespStatus {
                Status = "Success", Message = "Employment Type Details Updated!"
            }));
        }