public IActionResult SaveEntity(ClassifiedCategoryViewModel classifiedCategoryVm) { if (!ModelState.IsValid) { IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors); return(new BadRequestObjectResult(allErrors)); } if (classifiedCategoryVm.Id == 0) { _classifiedCategoryService.Add(classifiedCategoryVm); } else { _classifiedCategoryService.Update(classifiedCategoryVm); } _classifiedCategoryService.Save(); return(new OkObjectResult(classifiedCategoryVm)); }
public void Update(ClassifiedCategoryViewModel classifiedCategoryVm) { var classifiedCategory = Mapper.Map <ClassifiedCategoryViewModel, ClassifiedCategory>(classifiedCategoryVm); _classifiedCategoryRepository.Update(classifiedCategory); }