public static void addNewFile(File fileToAdd)
 {
     using (Online_RepositoryEntities context = new Online_RepositoryEntities())
     {
         context.Files.Add(fileToAdd);
         context.SaveChanges();
     }
 }
Exemple #2
0
        public static void deleteUserById(int id)
        {
            User userToDelete = getUserByID(id).FirstOrDefault();

            using (Online_RepositoryEntities context = new Online_RepositoryEntities())
            {
                context.Users.Remove(userToDelete);
                context.SaveChanges();
            }
        }
Exemple #3
0
        public static void changePassword(string newpassword, int id)
        {
            using (Online_RepositoryEntities context = new Online_RepositoryEntities())
            {
                User userToChangePassword = (from u in context.Users
                                             where u.UserId == id
                                             select u).FirstOrDefault();

                userToChangePassword.Password = newpassword;
                context.SaveChanges();
            }
        }
        public static void deleteFile(int id)
        {
            using (Online_RepositoryEntities context = new Online_RepositoryEntities())
            {
                File fileToDelete = (from f in context.Files
                                     where f.FileId == id
                                     select f).FirstOrDefault();

                context.Files.Remove(fileToDelete);
                context.SaveChanges();
            }
        }
Exemple #5
0
        public static void addNewUser(string uName, string email, string password)
        {
            int  id      = getMaxId() + 1;
            User newUser = new User();

            newUser.UserId    = id;
            newUser.Name      = uName;
            newUser.Password  = password;
            newUser.Authority = 2;
            newUser.Email     = email;
            using (Online_RepositoryEntities context = new Online_RepositoryEntities())
            {
                context.Users.Add(newUser);
                context.SaveChanges();
            }
        }