public JsonResult search(string name)
        {
            int res = 0;
            BaseCategory_Table    obj  = db.BaseCategory_Table.Where(x => x.BaseCatName == name && x.BaseCatIsDeleted == false).FirstOrDefault();
            ProductCategory_Table obj1 = db.ProductCategory_Table.Where(x => x.ProductCatName == name && x.ProductCatIsDeleted == false).FirstOrDefault();
            User_Table            obj2 = db.User_Table.Where(x => x.UserName == name && x.UserIsDeleted == false).FirstOrDefault();

            if (obj != null)
            {
                res = 1;
                Session["base_cat"] = obj.BaseCatId;
                var redirectUrl = new UrlHelper(Request.RequestContext).Action("Product_cat", "Buyer");
                return(Json(new { res, Url = redirectUrl }, JsonRequestBehavior.AllowGet));
            }
            else if (obj1 != null)
            {
                res = 1;
                Session["prod_cat"] = obj1.ProductCatId;
                var redirectUrl = new UrlHelper(Request.RequestContext).Action("Product_page", "Buyer");
                return(Json(new { res, Url = redirectUrl }, JsonRequestBehavior.AllowGet));
            }
            else if (obj2 != null)
            {
                res = 1;
                Session["brand_id"] = obj2.UserId;
                var redirectUrl = new UrlHelper(Request.RequestContext).Action("Brand_page", "Buyer");
                return(Json(new { res, Url = redirectUrl }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { res }, JsonRequestBehavior.AllowGet));
            }
        }
Example #2
0
        public JsonResult ProductCategoryDelete(int ProductCatId)
        {
            ShoppingCartDbEntities db          = new ShoppingCartDbEntities();
            ProductCategory_Table  procategory = db.ProductCategory_Table.Find(ProductCatId);                             // Details of patricular role to be deleted is obtained using it's id

            procategory.ProductCatIsDeleted = true;                                                                       //Obtained data record is made inactive by setting value of isdeleted field to one
            db.SaveChanges();
            bool result      = true;
            var  redirectUrl = new UrlHelper(Request.RequestContext).Action("ManageProductCategories", "Admin");           //passing url to which control to be navigated is stored in a variable

            return(Json(new { result, Url = redirectUrl }, JsonRequestBehavior.AllowGet));                                 //Values updated and url is returned back to ajax success function
        }
Example #3
0
        public ActionResult ManageProductCategories(ProductCategory_Table categories, string basecategory)             //new product category is passed as object of  ProductCategory_Table to post function ManageProductCategories
        {
            categories.BaseCatid             = Convert.ToInt32(basecategory);
            categories.ProductCatCreatedDate = DateTime.Now;
            categories.ProductCatCreatedBy   = Session["user"].ToString();
            categories.ProductCatUpdatedDate = DateTime.Now;
            categories.ProductCateUpdatedBy  = Session["user"].ToString();
            categories.ProductCatIsDeleted   = false;                                                           /* Values are added */
            db.ProductCategory_Table.Add(categories);                                                           //Adding values to ProductCategory_Table
            db.SaveChanges();



            return(RedirectToAction("ManageProductCategories"));
        }
Example #4
0
        public JsonResult ProductCategoryEdit(int ProductCatId, string ProductCatName, string ProductCatDescription)   //updated values are passed as parameters of post function through ajax method
        {
            ShoppingCartDbEntities db       = new ShoppingCartDbEntities();
            ProductCategory_Table  category = db.ProductCategory_Table.Find(ProductCatId);                             //Details of patricular product category to be edited is obtained using it's id
            var emp = (from u in db.ProductCategory_Table                                                              //Base Category Id of product category to be edited is found
                       where ProductCatId == u.ProductCatId
                       select u.BaseCatid).FirstOrDefault();

            category.BaseCatid             = emp;
            category.ProductCatName        = ProductCatName;
            category.ProductCatDesc        = ProductCatDescription;
            category.ProductCatUpdatedDate = DateTime.Now;
            category.ProductCateUpdatedBy  = Session["user"].ToString();
            category.ProductCatIsDeleted   = false;
            db.SaveChanges();
            var redirectUrl = new UrlHelper(Request.RequestContext).Action("ManageProductCategories", "Admin");                                                                          //passing url to which control to be navigated is stored in a variable

            return(Json(new { ProductCatId = ProductCatId, ProductCatName = ProductCatName, ProductCatDesc = ProductCatDescription, Url = redirectUrl }, JsonRequestBehavior.AllowGet)); //Values updated and url is returned back to ajax success function
        }