public ActionResult Login(CustomerViewModel cust)
 {
     try
     {
         if (WebSecurity.Login(cust.Username, cust.Password))
         {
             cust.GetCurrentProfile();
             Session["CustomerID"] = cust.CustomerID;
             Session["Message"] = "Welcome " + cust.Username;
             Session["LoginStatus"] = "logged in as " + cust.Username;
             return Json(new { url = Url.Action("") }, JsonRequestBehavior.AllowGet);
         }
         else
         {
             ViewBag.Message = "login failed - try again";
             return PartialView("PopupMessage");
         }
     }
     catch (Exception ex)
     {
         ViewBag.Message = "Severe Error on Login ";
         String exMSg = ex.Message;
         return PartialView("PopupMessage");
     }
 }
        public ActionResult Register(CustomerViewModel cust)
        {
            try
            {
                ViewBag.Message = "";
                WebSecurity.CreateUserAndAccount(cust.Username, cust.Password);
                cust.Register();
                if (cust.CustomerID > 0)
                {
                    ViewBag.Message = cust.Message;
                    MailMessage msg = new MailMessage();
                    msg.Subject = "New Registration";
                    msg.From = new MailAddress("*****@*****.**", "Camera Shack Registrar");
                    msg.To.Add(new MailAddress(cust.Email));
                    msg.Body = "Congratulations " + cust.Firstname +
                                ", you have been registered at Camera Shack!" +
                               " your new username is " + cust.Username;
                    SmtpClient mailClient = new SmtpClient();
                    mailClient.Send(msg);

                }
                else
                {
                    ViewBag.Message = "Problem Registering, try again later";
                    ((SimpleMembershipProvider)Membership.Provider).DeleteAccount(cust.Username);
                    ((SimpleMembershipProvider)Membership.Provider).DeleteUser(cust.Username, true);
                }
                ViewBag.Message = cust.Message;
                return PartialView("PopupMessage");
            }
            catch (MembershipCreateUserException e)
            {
                ViewBag.Message = ErrorCodeToString(e.StatusCode);
                return PartialView("PopupMessage");
            }
        }