public bool UpdateCategroy(CategroyViewModel categroyViewModel) { var category = Mapper.Map <Category>(categroyViewModel); TheUnitOfWork.Category.Update(category); TheUnitOfWork.Commit(); return(true); }
public void UpdateCategory() { CategroyViewModel categroy = new CategroyViewModel { Id = 5, Name = "clothes" }; var result = categroyAppService.UpdateCategroy(categroy); Assert.That(result, Is.True); }
public void InsertCategory_Test() { CategroyViewModel categroy = new CategroyViewModel(); categroy.Name = "Cloth"; var result = categroyAppService.SaveNewCategroy(categroy); Assert.That(result, Is.True); }
public ActionResult Edit(CategroyViewModel categroy) { if (!ModelState.IsValid) { return(View(categroy)); } categroyAppService.UpdateCategroy(categroy); return(RedirectToAction("Index")); }
public void InsertExitingCategory() { CategroyViewModel categroy = new CategroyViewModel(); categroy.Name = "Cloth"; categroy.Id = 5; var result = categroyAppService.SaveNewCategroy(categroy); Assert.That(result, Is.False); }
public ActionResult Create(CategroyViewModel newCategory) { if (!ModelState.IsValid) { return(View(newCategory)); } bool result = categroyAppService.SaveNewCategroy(newCategory); if (result == false) { ViewBag.CategoryIsExist = true; return(View(newCategory)); } ViewBag.CategoryIsExist = false; return(RedirectToAction("Index")); }
//insert public bool SaveNewCategroy(CategroyViewModel categroyViewModel) { bool result = false; CategroyViewModel CatVM = this.GetAllCategroy().Where(c => c.Name == categroyViewModel.Name).FirstOrDefault(); if (CatVM != null) { return(result); } var category = Mapper.Map <Category>(categroyViewModel); if (TheUnitOfWork.Category.Insert(category)) { result = TheUnitOfWork.Commit() > new int(); } return(result); }
public ActionResult Edit(int id) { CategroyViewModel categroy = categroyAppService.GetCategroyById(id); return(View(categroy)); }
public bool CheckCategoryExists(CategroyViewModel categroyViewModel) { Category category = Mapper.Map <Category>(categroyViewModel); return(TheUnitOfWork.Category.CheckCategroyExists(category)); }