public ActionResult AccountDetails(FormCollection formCollection)
 {
     String editSuccess = UserModel.editProfile(User.Identity.Name, formCollection);
     if (editSuccess != "")
         ModelState.AddModelError("", editSuccess);
     UserModel pModel = new UserModel(User.Identity.Name);
     return View(pModel);
 }
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.email, model.Password, persistCookie: model.RememberMe))
            {
                UserModel profile = new UserModel(model.email);
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                    1,
                    model.email,
                    DateTime.Now,
                    DateTime.Now.AddDays(1),
                    model.RememberMe,
                    profile.first_name + "|" + profile.last_name + "|" + WebSecurity.CurrentUserId + "|" + profile.dob + "|" + profile.gender,
                    FormsAuthentication.FormsCookiePath);
                string hashCookies = FormsAuthentication.Encrypt(ticket);
                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hashCookies);
                Response.Cookies.Add(cookie);

                //Load Shopping Cart into the session
                int userId = WebSecurity.GetUserId(model.email);
                Session["UserId"] = userId;
                Session["ShoppingCart"] = ShoppingCartModel.GetInstance(userId);

                Response.Cookies.Add(NavigationModel.recentProductsViewedCookie(userId, 10));
                Response.Cookies.Add(NavigationModel.recentStoreViewedCookie(userId, 10));

                return RedirectToLocal(returnUrl);
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The email or password provided is incorrect.");
            return View(model);
        }
        public StoreInformationModel(Store s, Boolean min = false, SIEBUEntities db = null)
        {
            if (db == null) db = new SIEBUEntities();

            id = s.s_id;
            name = s.name;
            store_namespace = s.name_space;
            logo = s.logo;
            category = s.category_id;
            status = (s.status.HasValue ? s.status.Value : -1);
            description = s.description;
            banner = s.banner_img;
            background = s.background_img;
            owner_name = s.User.firstName + " " + s.User.lastName;
            social_media = SocialMediaModel.getSocialMedia(s, db);
            email = (s.Store_Contact.Count(c => c.Contact.caption == "Email Address") > 0 ? s.Store_Contact.Where(c => c.Contact.caption == "Email Address").FirstOrDefault().value : "");
            website = (s.Store_Contact.Count(c => c.Contact.caption == "Website") > 0 ? s.Store_Contact.Where(c => c.Contact.caption == "Website").FirstOrDefault().value : "");

            if (s.created_on.HasValue)
                created_date = s.created_on.Value;

            UserModel owner = new UserModel(s.User, db);
            owners = new List<UserModel>();
            owners.Add(owner);
        }