Ejemplo n.º 1
0
        //Adding value in selling category checkbox.
        public JsonResult AddSellingCategory(string sell)
        {
            SellingCategoryModel vp = new SellingCategoryModel();
            var a = db.sellcategory.Where(x => x.hobbyname == sell && (x.IsDeleted == false)).ToList();

            if (a.Count() > 0)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            vp.hobbyname = sell;
            db.sellcategory.Add(vp);
            db.SaveChanges();
            return(Json(true, JsonRequestBehavior.AllowGet));


            //if (Session["superid"] != null)
            //{
            //    if(scm.hobbyname != null)
            //    {
            //        db.sellcategory.Add(scm);
            //        db.SaveChanges();
            //        return RedirectToAction("AdminPortal");
            //    }
            //    else
            //    {
            //        ViewBag.smsg = "Blank field can't be inserted.";
            //        return View();
            //    }
            //}
            //else
            //{
            //    ViewBag.smsg = "Please login first.";
            //    return View();
            //}
        }
Ejemplo n.º 2
0
        public JsonResult EditCategory(string EditValue, int catId)
        {
            bool result             = false;
            SellingCategoryModel vp = new SellingCategoryModel();

            vp           = db.sellcategory.Where(x => x.Id == catId).FirstOrDefault();
            vp.hobbyname = EditValue;
            db.SaveChanges();
            result = true;
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public ActionResult vendor(VendorViewModel vvm, List <SellingCategoryModel> hobby)
        {
            try
            {
                foreach (var it in hobby.Where(x => x.IsChecked).ToList())
                {
                    if (it.IsChecked)
                    {
                        var id = db.sellcategory.Find(it.Id);
                        id.IsUsed = true;
                    }
                }
                var str1 = "";
                foreach (var item in hobby.Where(x => x.IsChecked).ToList())
                {
                    if (item.IsChecked)
                    {
                        str1 += item.hobbyname.ToString() + ",";
                    }
                }
                str1 = str1.TrimEnd(',');
                string p                 = vvm.VendorPassword + "@" + "vms";
                string password          = Encrypt_Password(p);
                SellingCategoryModel scm = new SellingCategoryModel();
                scm.IsUsed = true;
                VendorModel vm = new VendorModel();
                vm.SellingCategory = str1;
                vm.VendorContact   = vvm.VendorContact;
                vm.VendorEmail     = vvm.VendorEmail;
                vm.VendorName      = vvm.VendorName;
                vm.VendorPassword  = password;
                db.vendor.Add(vm);
                db.SaveChanges();

                int i = db.vendor.Where(x => x.VendorEmail == vvm.VendorEmail).Select(x => x.VendorId).FirstOrDefault();
                //Adding roles to vendor
                UserRoles uRole = new UserRoles();
                uRole.RoleName = "Vendor";
                uRole.VendorId = i;
                db.userrole.Add(uRole);
                db.SaveChanges();

                //Adding session to complete the form. It will identify every registration forms value to particular vendor.
                Session["Admin"] = i;
                return(RedirectToAction("PCDetails", "VendorDetails"));
            }
            catch (Exception)
            {
                ViewBag.value = "Something went wrong";
                return(View());
            }
        }