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)); }
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); }
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 }); }
public async Task UpdateCategory(JobCategoryViewModel model) { var mapped = _mapper.Map <JobCategory>(model); await _jobCategoryRepository.Update(mapped); }