예제 #1
0
        public bool UpdateCategroy(CategroyViewModel categroyViewModel)
        {
            var category = Mapper.Map <Category>(categroyViewModel);

            TheUnitOfWork.Category.Update(category);
            TheUnitOfWork.Commit();
            return(true);
        }
예제 #2
0
        public void UpdateCategory()
        {
            CategroyViewModel categroy = new CategroyViewModel {
                Id = 5, Name = "clothes"
            };
            var result = categroyAppService.UpdateCategroy(categroy);

            Assert.That(result, Is.True);
        }
예제 #3
0
        public void InsertCategory_Test()
        {
            CategroyViewModel categroy = new CategroyViewModel();

            categroy.Name = "Cloth";
            var result = categroyAppService.SaveNewCategroy(categroy);

            Assert.That(result, Is.True);
        }
예제 #4
0
        public ActionResult Edit(CategroyViewModel categroy)
        {
            if (!ModelState.IsValid)
            {
                return(View(categroy));
            }

            categroyAppService.UpdateCategroy(categroy);
            return(RedirectToAction("Index"));
        }
예제 #5
0
        public void InsertExitingCategory()
        {
            CategroyViewModel categroy = new CategroyViewModel();

            categroy.Name = "Cloth";
            categroy.Id   = 5;
            var result = categroyAppService.SaveNewCategroy(categroy);

            Assert.That(result, Is.False);
        }
예제 #6
0
        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"));
        }
예제 #7
0
        //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);
        }
예제 #8
0
        public ActionResult Edit(int id)
        {
            CategroyViewModel categroy = categroyAppService.GetCategroyById(id);

            return(View(categroy));
        }
예제 #9
0
        public bool CheckCategoryExists(CategroyViewModel categroyViewModel)
        {
            Category category = Mapper.Map <Category>(categroyViewModel);

            return(TheUnitOfWork.Category.CheckCategroyExists(category));
        }