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));
            }
        }
Beispiel #2
0
        public JsonResult BaseCategoryDelete(int BaseCatId)
        {
            ShoppingCartDbEntities db           = new ShoppingCartDbEntities();
            BaseCategory_Table     basecategory = db.BaseCategory_Table.Find(BaseCatId);                        // Details of patricular role to be deleted is obtained using it's id

            basecategory.BaseCatIsDeleted = 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("ManageBaseCategories", "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
        }
Beispiel #3
0
        public ActionResult ManageBaseCategories(BaseCategory_Table category)                                          //new object of BaseCategory_Table are passed to post function ManageBaseCategories
        {
            category.BaseCatCreateDate = DateTime.Now;
            category.BaseCatCreatedBy  = Session["user"].ToString();
            category.BaseCatUpdateDate = DateTime.Now;
            category.BaseCatUpdatedBy  = Session["user"].ToString();
            category.BaseCatIsDeleted  = false;                                                                        /* Values are added */
            db.BaseCategory_Table.Add(category);                                                                       //Adding values to Role_Table
            db.SaveChanges();


            return(RedirectToAction("ManageBaseCategories"));
        }
Beispiel #4
0
        public JsonResult BaseCategoryEdit(int BaseCatId, string BaseCatName, string BaseCatDescription)   //updated values are passed as parameters of post function through ajax method
        {
            ShoppingCartDbEntities db       = new ShoppingCartDbEntities();
            BaseCategory_Table     category = db.BaseCategory_Table.Find(BaseCatId);                        //Details of patricular base category to be edited is obtained using it's id

            category.BaseCatName = BaseCatName;
            category.BaseCatDesc = BaseCatDescription;

            category.BaseCatUpdatedBy  = Session["user"].ToString();
            category.BaseCatIsDeleted  = false;
            category.BaseCatUpdateDate = DateTime.Now;
            db.SaveChanges();
            var redirectUrl = new UrlHelper(Request.RequestContext).Action("ManageBaseCategories", "Admin");                                                           //passing url to which control to be navigated is stored in a variable

            return(Json(new { BaseCatId = BaseCatId, BaseCatName = BaseCatName, BaseCatDesc = BaseCatDescription, Url = redirectUrl }, JsonRequestBehavior.AllowGet)); //Values updated and url is returned back to ajax success function
        }