public ActionResult CategoryAdd(Category newItem)
        {
            if (!ModelState.IsValid)
            {
                return(View(newItem));
            }

            var addedItem = AdminManager.AddCategory(newItem);

            if (addedItem == null)
            {
                return(View(newItem));
            }
            else
            {
                return(RedirectToAction("CategoryList"));
            }
        }
Пример #2
0
        public async Task TestAddCategory_success(int cid, string cname, string cdetails)
        {
            try
            {
                CategoryModel cat = new CategoryModel();
                cat.Cid      = cid;
                cat.Cname    = cname;
                cat.Cdetails = cdetails;
                await _manager.AddCategory(cat);

                var x = _manager.getCategoryid(cat.Cid);
                Assert.NotNull(x);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.InnerException.Message);
            }
        }
Пример #3
0
        public async Task TestAddCategory_success(int cid, string cname, string cdetails)
        {
            try
            {
                CategoryModel cat = new CategoryModel
                {
                    Cid      = cid,
                    Cname    = cname,
                    Cdetails = cdetails
                };
                _iadmin.Setup(x => x.AddCategory(cat)).ReturnsAsync(true);
                AdminManager mg  = new AdminManager(_iadmin.Object);
                var          res = await mg.AddCategory(cat);

                Assert.AreEqual(true, res);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.InnerException.Message);
            }
        }