public ActionResult Create([Bind(Include = "Category_ID,Category_Name,Category_ImageName")] tbl_Categories tbl_Categories, HttpPostedFileBase file)
        {
            using (Store_DB db = new Store_DB())
            {
                if (file != null)
                {
                    string pathToSave = Server.MapPath(@"~/Content/Uploads/Categories/");

                    //tbl_Categories.Category_ImageName = file.FileName;

                    var createCategory = new tbl_Categories()
                    {
                        Category_Name      = tbl_Categories.Category_Name,
                        Category_ImagePath = pathToSave
                    };
                    string NewFileName = String.Format("{0}.png", createCategory.Category_Name);
                    createCategory.Category_ImageName = NewFileName;
                    file.SaveAs(Path.Combine(pathToSave, NewFileName));

                    db.tbl_Categories.Add(createCategory);
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }

            return(View(tbl_Categories));
        }
        public ActionResult Login(AccountsModel user)
        {
            using (Store_DB db = new Store_DB())
            {
                var userLogin = (db.tbl_Accounts.SingleOrDefault(u => u.Account_UserName.ToLower() == user.AccountUserName.ToLower() && u.Account_Password == user.AccountPassword));

                if (userLogin != null)
                {
                    Session["AccountID"]       = userLogin.Account_ID;
                    Session["AccountUserName"] = userLogin.Account_UserName.ToLower();
                    return(RedirectToAction("Index", "Home"));
                }
                ModelState.AddModelError("", "User name or Password is incorrect!");
            }
            return(View());
        }
        public ActionResult Register()
        {
            Store_DB db = new Store_DB();

            List <tbl_Cities> cityList = (from data in db.tbl_Cities
                                          select data).ToList();
            tbl_Cities objCities = new tbl_Cities();

            objCities.City_Name = "Select City";
            objCities.City_ID   = 0;
            cityList.Insert(0, objCities);
            SelectList objCityModel = new SelectList(cityList, "City_ID", "City_Name", 0);

            AccountsModel objModelForCity = new AccountsModel();

            objModelForCity.AccountCityList = objCityModel;

            return(View(objModelForCity));
        }
        // GET: Categories
        public ActionResult Index()
        {
            tbl_Categories    Category    = new tbl_Categories();
            tbl_SubCategories SubCategory = new tbl_SubCategories();
            Store_DB          db          = new Store_DB();

            foreach (var item in db.tbl_Categories)
            {
                //item.Category_ImagePath = "~/Content/Uploads/Categories/" + item.Category_ImageName;
                item.Category_ImagePath = "~/Content/Uploads/Categories/" + item.Category_ImageName;
            }

            //if (Category.Category_ImageName == db.tbl_Categories.FirstOrDefault().Category_ImageName)
            //{
            //    Category.Category_ImageName = "~/Content/Uploads/Categories/" + Category.Category_ID.ToString() + ".png";
            //}

            return(View(db.tbl_Categories.ToList()));
        }
        public ActionResult Register(AccountsModel user, int Cityid)
        {
            using (Store_DB db = new Store_DB())
            {
                List <tbl_Cities> cityList = (from data in db.tbl_Cities
                                              select data).ToList();
                tbl_Cities objCities = new tbl_Cities();
                objCities.City_Name = "Select City";
                objCities.City_ID   = 0;
                cityList.Insert(0, objCities);
                SelectList objCityModel = new SelectList(cityList, "City_ID", "City_Name", 0);

                AccountsModel objModelForCity = new AccountsModel();
                objModelForCity.AccountCityList = objCityModel;

                var accountCitySelected = ViewBag.City_Name = cityList.Where(c => c.City_ID == Cityid).FirstOrDefault().City_Name;

                if (ModelState.IsValid)
                {
                    var createAccount = new tbl_Accounts()
                    {
                        Account_FirstName    = user.AccountFirstName,
                        Account_LastName     = user.AccountLastName,
                        Account_BirthDate    = user.AccountBirthDate,
                        Account_City         = accountCitySelected,
                        Account_EmailAddress = user.AccountEmailAddress,
                        Account_UserName     = user.AccountUserName,
                        Account_Password     = user.AccountPassword,
                        Account_Mobile       = user.AccountMobile,
                        Account_Phone        = user.AccountPhone,
                        Account_CreatedDate  = user.AccountCreateDate
                    };

                    db.tbl_Accounts.Add(createAccount);
                    db.SaveChanges();

                    return(RedirectToAction("Index", "Home"));
                }

                return(View(objModelForCity));
            }
        }