public ActionResult Registration(UserClass usr)
        {
            string ResultRegistration = null;
            bool result = true;
            usr = new UserClass();
            TryUpdateModel<UserClass>(usr);

            if (ModelState.IsValid)
            {
                int i = 0;
                foreach (var userPresentDB in _db.Users)
                {
                    if ((userPresentDB.FirstName == usr.FirstName) && (userPresentDB.LastName == usr.LastName) && (userPresentDB.Mail == usr.Mail))
                    {
                        ResultRegistration = "Risulti già registrato";
                        result = false;
                        break;
                    }
                    i++;
                }
                if (result == true)
                {
                    Users addUser = new Users();
                    addUser.FirstName = usr.FirstName;
                    addUser.LastName = usr.LastName;
                    addUser.ID = i.ToString();
                    addUser.Mail = usr.Mail;
                    _db.Users.AddObject(addUser);
                    ResultRegistration = "La Registrazione è avvenuta con successo";
                }
                if (ModelState.IsValid)
                {

                    MailMessage msgeme = new MailMessage("*****@*****.**", usr.Mail, "Registrazione", "Ciao, la tua registrazione è avvenuta con successo");
                    SmtpClient stmClient = new SmtpClient("stmp.gmail.com", 587);
                    stmClient.EnableSsl = true;
                    stmClient.Credentials = new NetworkCredential("*****@*****.**", usr.Password);
                    stmClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                    stmClient.Send(msgeme);
                }

                return View(ResultRegistration);
            }
            else
            {
                return View(usr);
            }
        }
 /// <summary>
 /// Create a new Users object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 /// <param name="mail">Initial value of the Mail property.</param>
 public static Users CreateUsers(global::System.String id, global::System.String firstName, global::System.String lastName, global::System.String mail)
 {
     Users users = new Users();
     users.ID = id;
     users.FirstName = firstName;
     users.LastName = lastName;
     users.Mail = mail;
     return users;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUsers(Users users)
 {
     base.AddObject("Users", users);
 }