public JsonResult DeclineUser(int UserId) { ShoppingCartDbEntities db = new ShoppingCartDbEntities(); var confirmuser = (from u in db.User_Table where u.UserId == UserId select u).FirstOrDefault(); //To decline user its details is taken from db confirmuser.UserIsDeleted = true; //User is accepted by setting UserIsDeleted = false that user is made active confirmuser.UserUpdatedDate = DateTime.Now; confirmuser.UserUpdateBy = Session["user"].ToString(); TempData["user"] = confirmuser.UserName; if (confirmuser.Roleid == 2) { var seller = (from s in db.Product_Table where s.SellerId == UserId select s).ToList(); foreach (var item in seller) { item.ProductIsDeleted = true; } } else if (confirmuser.Roleid == 3) { var service = (from sp in db.Service_Table where sp.ServiceProviderid == UserId select sp).ToList(); foreach (var item in service) { item.ServiceIsDeleted = true; } } db.SaveChanges(); bool result = true; var redirectUrl = new UrlHelper(Request.RequestContext).Action("SendMail", "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 }
/// <summary> /// To Manage different base categories of products in a Online Shopping Site /// </summary> /// <returns></returns> public ActionResult ManageBaseCategories() { ShoppingCartDbEntities db = new ShoppingCartDbEntities(); var categories = (from b in db.BaseCategory_Table where b.BaseCatIsDeleted == false select b).ToList(); ViewBag.BaseCategories = categories; return(View()); }
/// <summary> /// To Manage different roles in Online Shopping Site /// </summary> /// <returns></returns> public ActionResult ManageRole() { ShoppingCartDbEntities db = new ShoppingCartDbEntities(); var roles = (from r in db.Role_Table where r.RoleIsDeleted == false select r).ToList(); /*Getting roles created from Role_Table if * role that is checking whether value of RoleIsDeleted=0*/ ViewBag.Roles = roles; //passing list to Viewbag //ViewBag.message = null; return(View()); }
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 }
public JsonResult RoleDelete(int RoleId) { ShoppingCartDbEntities db = new ShoppingCartDbEntities(); Role_Table role = db.Role_Table.Find(RoleId); //Details of patricular role to be deleted is obtained using it's id role.RoleIsDeleted = true; db.SaveChanges(); //Db is updated bool result = true; var redirectUrl = new UrlHelper(Request.RequestContext).Action("ManageRole", "Admin"); //passing url to which control to be navigated is stored in a variable return(Json(new { result, Url = redirectUrl }, JsonRequestBehavior.AllowGet)); }
public JsonResult RoleEdit(int RoleId, string RoleName, string RoleDescription) //updated values are passed as parameters of post function through ajax method { ShoppingCartDbEntities db = new ShoppingCartDbEntities(); Role_Table role = db.Role_Table.Find(RoleId); //Details of patricular role is obtained using it's id role.RoleName = RoleName; /*Rest of values are updated*/ role.RoleDesc = RoleDescription; role.RoleUpdatedBy = Session["user"].ToString(); role.RoleIsDeleted = false; role.RoleUpdateDate = DateTime.Now; db.SaveChanges(); //Db is updated var redirectUrl = new UrlHelper(Request.RequestContext).Action("ManageRole", "Admin"); //passing url to which control to be navigated is stored in a variable return(Json(new { RoleId = RoleId, RoleName = RoleName, RoleDesc = RoleDescription, Url = redirectUrl }, JsonRequestBehavior.AllowGet)); //Values updated and url is returned back to ajax success function }
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 }
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 }
public ActionResult Create(Image_Table model, Product_Table product) { int j; Notification_Count(); Image_Table image = new Image_Table(); if (ModelState.IsValid) { ShoppingCartDbEntities db = new ShoppingCartDbEntities(); string name = Session["user"].ToString(); int id = (from user in db.User_Table where user.UserName == name select user.UserId).FirstOrDefault(); product.SellerId = id; product.ProductCreatedBy = Session["user"].ToString(); product.ProductCreatedDate = DateTime.Now; product.ProductUpdatedBy = Session["user"].ToString(); product.ProductUpdatedDate = DateTime.Now; product.ProductIsDeleted = false; db.Product_Table.Add(product); db.SaveChanges(); object[] imgarray = new object[5]; int p = product.ProductId; HttpPostedFileBase file = Request.Files["ImageData"]; for (j = 0; j < Request.Files.Count; j++) { file = Request.Files[j]; ContentRepository service = new ContentRepository(); if (file.FileName != "") { image = service.UploadImageInDataBase(file, model); Image_Table imageObj = new Image_Table(); imageObj.BinaryImage = image.BinaryImage; imageObj.Productid = product.ProductId; imageObj.ImageCreatedBy = Session["user"].ToString(); imageObj.ImageCreatedDate = DateTime.Now; imageObj.ImageUpdatedBy = Session["user"].ToString(); imageObj.ImageUpdatedDate = DateTime.Now; imageObj.ImageIsDeleted = false; db.Image_Table.Add(imageObj); db.SaveChanges(); } else if (file.FileName == "") { TempData["null_image"] = "Cannot Upload Null Image"; return(RedirectToAction("Create")); } else { TempData["not_image"] = "this is not an image file"; return(RedirectToAction("Create")); } } } return(RedirectToAction("display")); }