public ActionResult Index(user user, string userBirth)
 {
     var userSession = (user)Session["user"];
     user.email = userSession.email;
     DateTime newBirthDate = Convert.ToDateTime(userBirth);
     UserPanel modelPanel = new UserPanel();
     using (var db = new HotelDBEntities())
     {
         user currentUser = db.users.FirstOrDefault(u => u.email == user.email);
         if (String.IsNullOrEmpty(user.name) || String.IsNullOrEmpty(user.surname))
         {
             modelPanel.user = currentUser;
             modelPanel.info.type = 0;
             modelPanel.info.text = "You didn't fill name or surname, please fill those fields.";
             return View(modelPanel);
         }
         if (!(String.IsNullOrEmpty(user.password)) && (user.password.Length > 10 || user.password.Length < 6))
         {
             modelPanel.user = currentUser;
             modelPanel.info.type = 0;
             modelPanel.info.text = "Password must be between 6 and 10 characters.";
             return View(modelPanel);
         }
         if (!(String.IsNullOrEmpty(user.password)) && (user.password.Length < 10 || user.password.Length > 6))
         {
             var crypto = new SimpleCrypto.PBKDF2();
             var encrPass = crypto.Compute(user.password);
             currentUser.password = encrPass;
             currentUser.password_salt = crypto.Salt;
         }
         currentUser.name = user.name;
         currentUser.surname = user.surname;
         currentUser.country = user.country;
         currentUser.birth_date = newBirthDate;
         db.users.Attach(currentUser);
         db.Entry(currentUser).Property(p => p.password).IsModified = true;
         db.Entry(currentUser).Property(p => p.password_salt).IsModified = true;
         db.Entry(currentUser).Property(p => p.name).IsModified = true;
         db.Entry(currentUser).Property(p => p.surname).IsModified = true;
         db.Entry(currentUser).Property(p => p.country).IsModified = true;
         db.Entry(currentUser).Property(p => p.birth_date).IsModified = true;
         db.SaveChanges();
         modelPanel.user = currentUser;
         modelPanel.info.type = 1;
         modelPanel.info.text = "Your data has been changed.";
         return View(modelPanel);
     }
 }
 public ActionResult Index()
 {
     if (Session["user"] == null)
     {
         return RedirectToAction("Index", "Home");
     }
     else
     {
         using (var db = new HotelDBEntities())
         {
             user userSession = (user)Session["user"];
             UserPanel modelPanel = new UserPanel();
             modelPanel.user = db.users.FirstOrDefault(u => u.email == userSession.email);
             return View(modelPanel);
         }
     }
 }