Example #1
0
        public ActionResult AddTestCat(int?cat_id, tblTestCategory obj)
        {
            string     username = "";
            HttpCookie cookie   = HttpContext.Request.Cookies["AdminCookies"];

            if (cookie != null)
            {
                username = Convert.ToString(cookie.Values["UserName"]);
            }

            try
            {
                // TODO: Add insert logic here
                if (cat_id != null)
                {
                    obj.ID = Convert.ToInt32(cat_id);
                    new TestDAL().UpdateTestCategory(obj);
                    TempData["AlertTask"] = "Test updated successfully";
                }
                else
                {
                    cat_id = new TestDAL().AddTestCategory(obj);
                    TempData["AlertTask"] = "Test added successfully";
                }

                return(Redirect("/test-categories"));
            }
            catch
            {
                return(View());
            }
        }
Example #2
0
        public ActionResult AddTestCat(int?cat_id)
        {
            var model = new tblTestCategory();

            if (cat_id != null)
            {
                model = new TestDAL().GetTestCategory(Convert.ToInt32(cat_id));
            }
            return(View(model));
        }