public Category MapCategoryInputToExistingEntity(CategoryInput categoryInput, Category categoryEntityToUpdate) { categoryEntityToUpdate.Description = categoryInput.Description; categoryEntityToUpdate.Name = categoryInput.Name; categoryEntityToUpdate.UrlSlug = categoryInput.UrlSlug; return categoryEntityToUpdate; }
public Category MapCategoryInputToNewEntity(CategoryInput categoryInput) { return new Category { Description = categoryInput.Description, Name = categoryInput.Name, UrlSlug = categoryInput.UrlSlug }; }
public ActionResult CreateCategory(CategoryInput categoryInput) { if (!ModelState.IsValid) { return View("CreateCategory", categoryInput); } _adminService.CreateCategory(categoryInput); return RedirectToAction("ManageCategories"); }
public void CreateCategory(CategoryInput categoryInput) { var category = _mapper.MapCategoryInputToNewEntity(categoryInput); _categoriesRepository.Insert(category); }
public void UpdateCategory(CategoryInput categoryInput) { var categoryEntityToUpdate = _categoriesRepository.GetById(categoryInput.CategoryId); var category = _mapper.MapCategoryInputToExistingEntity(categoryInput, categoryEntityToUpdate); _categoriesRepository.Update(category); }