예제 #1
0
        public async Task <ActionResult <JobCategoryDto> > Update(int id, JobCategoryRequest model)
        {
            var jobCategory = await _repository.Update(id, model);

            return(jobCategory != null
                ? Accepted(nameof(Update), jobCategory)
                : StatusCode(StatusCodes.Status500InternalServerError, null));
        }
예제 #2
0
        public async Task <bool> Edit(JobCategory item)
        {
            var category = await _repo.GetById(item.JobCategoryId);

            category.Name = item.Name;

            try
            {
                _repo.Update(category);
                await _unitOfWork.Save();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(false);
            }

            return(true);
        }
예제 #3
0
 public OutputBase CreateOrUpdateJobCategory(CreateOrUpdateJobCategoryInput input)
 {
     if (
         _jobCategoryRepository.Query(
             q => q.Any(jc => jc.Name == input.JobCategory.Name && jc.Id != input.JobCategory.Id)))
     {
         return(new OutputBase {
             Message = "A category with the same already added", Success = false
         });
     }
     if (input.JobCategory.Id == 0)
     {
         _jobCategoryRepository.Insert(Mapper.Map <JobCategory>(input.JobCategory));
     }
     else
     {
         _jobCategoryRepository.Update(Mapper.Map <JobCategory>(input.JobCategory));
     }
     return(new OutputBase {
         Message = "Category saved", Success = true
     });
 }
예제 #4
0
 public async Task UpdateCategory(JobCategoryViewModel model)
 {
     var mapped = _mapper.Map <JobCategory>(model);
     await _jobCategoryRepository.Update(mapped);
 }