public static bool AddUser(User newUser)
 {
     using (var db = new TwitterOnVaadinEntities())
     {
         if (db.Users.FirstOrDefault(e => e.Username == newUser.Username) != null)
         {
             db.Users.AddObject(newUser);
             db.SaveChanges();
             return true;
         }
         return false;
     }
 }
 public bool AddNewUser(string Username, string Forename, string Surname, int Age, string Password, string Photo)
 {
     try
     {
         var userDb = new User
         {
             Username = Username,
             Forename = Forename,
             Surname = Surname,
             Age = Age,
             Password = Password,
             Photo = Photo,
             Admin = false,
             Ban = false,
         };
         var res = DataFunctions.AddUser(userDb);
     }
     catch (Exception ex)
     {
         //TODO:Logging
         return false;
     }
     return true;
 }
 public static bool UpdateUser(User newUser)
 {
     using (var db = new TwitterOnVaadinEntities())
     {
         var user = db.Users.FirstOrDefault(e => e.id == newUser.id);
         if (user != null)
         {
             user = newUser;
         }
         db.SaveChanges();
     }
     return true;
 }
 public static User GetUser(string username, string password)
 {
     var user = new User();
     using (var db = new TwitterOnVaadinEntities())
     {
         user = db.Users.ToList().FirstOrDefault(e => e.Username == username && e.Password == password);
         //if (userDb != null)
         //{
         //    user.Username = userDb.Username;
         //    user.Forename = userDb.Forename;
         //    user.Surname = userDb.Surname;
         //    user.Age = userDb.Age;
         //    user.Password = userDb.Password;
         //    user.Photo = userDb.Photo;
         //    user.id = userDb.id;
         //    user.Admin = userDb.Admin;
         //    user.Ban = userDb.Ban;
         //}
     }
     return user;
 }
 public bool UpdateUser(string Username, string Forename, string Surname, int Age, string Password, string Photo, bool Ban, int Id)
 {
     try
     {
        var userDb = new User
        {
             Username = Username,
             Forename = Forename,
             Surname = Surname,
             Age = Age,
             Password = Password,
             Photo = Photo,
             id = Id,
             Ban = Ban,
        };
        var res = DataFunctions.UpdateUser(userDb);
     }catch(Exception ex)
     {
         //TODO:Logging
         return false;
     }
     return true;;
 }
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="username">Initial value of the Username property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 /// <param name="admin">Initial value of the Admin property.</param>
 /// <param name="ban">Initial value of the Ban property.</param>
 public static User CreateUser(global::System.Int32 id, global::System.String username, global::System.String password, global::System.Boolean admin, global::System.Boolean ban)
 {
     User user = new User();
     user.id = id;
     user.Username = username;
     user.Password = password;
     user.Admin = admin;
     user.Ban = ban;
     return user;
 }
 /// <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(User user)
 {
     base.AddObject("Users", user);
 }