Пример #1
0
        public ActionResult EditUsers(FormCollection collection)
        {
            Image image = new Image();
            HttpPostedFileBase file;
            try
            {
                aspnet_User User = new aspnet_User();//userRep.showUser(id);
                UpdateModel(User);
                String i = User.UserName;
                User = userRep.showUser(i);
                int imgId = User.imageId;

                file = Request.Files[0];
                //Logikk for å få bilde inn i databasen
                if (file.ContentLength > 0)
                {
                    image.imageName = file.FileName;
                    image.imageSize = file.ContentLength;
                    image.imageType = file.ContentType;
                    byte[] theImage = new byte[file.ContentLength];
                    file.InputStream.Read(theImage, 0, (int)file.ContentLength);
                    image.image1 = theImage;
                    User.imageId = messageRep.addImage(image);
                    messageRep.deleteFile(messageRep.getFile(imgId));
                }

                userRep.updateUser(User);

                return RedirectToAction("DetailsUsers/" + User.UserName);
            }
            catch
            {
                return View();
            }
        }
 partial void Updateaspnet_User(aspnet_User instance);
 partial void Deleteaspnet_User(aspnet_User instance);
 partial void Insertaspnet_User(aspnet_User instance);
Пример #5
0
 /// <summary>
 /// Sletter en bruker
 /// </summary>
 /// <param name="user">en bruker</param>
 public void deleteUser(aspnet_User user)
 {
     db.aspnet_Users.DeleteOnSubmit(user);
     db.SubmitChanges();
 }
Пример #6
0
 /// <summary>
 /// Oppdaterer en bruker
 /// </summary>
 /// <param name="user">en bruker</param>
 public void updateUser(aspnet_User user)
 {
     db.SubmitChanges();
 }
Пример #7
0
 /// <summary>
 /// Henter alle brukere untatt de du har tilatt
 /// </summary>
 /// <param name="userId">liste med Permitted_user</param>
 /// <returns>liste fra aspnet_User tabellen</returns>
 public List<aspnet_User> showUsersNotInChatroom(List<Permitted_user> userId)
 {
     List<aspnet_User> users = showAllUsers().ToList();
     List<aspnet_User> tempUsers = showAllUsers().ToList();
     aspnet_User user = new aspnet_User();
     foreach (Permitted_user us in userId)
     {
         foreach (aspnet_User u in tempUsers)
         {
             if (u.UserId == us.UserId)
                 users.Remove(u);
         }
     }
     return users;
 }
Пример #8
0
 /// <summary>
 /// Henter liste over alle brukere som ikke er bannet fra rommet
 /// </summary>
 /// <param name="userId">liste med bannede brukere</param>
 /// <returns>liste med brukere som ikke er bannet</returns>
 public List<aspnet_User> showUnBannedUsers(List<Banned_user> userId)
 {
     List<aspnet_User> users = showAllUsers().ToList();
     List<aspnet_User> tempUsers = showAllUsers().ToList();
     aspnet_User user = new aspnet_User();
     foreach (Banned_user us in userId)
     {
         foreach (aspnet_User u in tempUsers)
         {
             if (u.UserId == us.UserId)
                 users.Remove(u);
         }
     }
     return users;
 }