Esempio n. 1
0
        public User UpdateUser(User user)
        {
            //Place _user object in context
            User _user = _context.Users.Find(user.ID);

            //Dress up the _user object as the user object
            _user.Name          = user.Name;
            _user.Password      = user.Password;
            _user.UserType      = user.UserType;
            _user.LastLoginDate = user.LastLoginDate;
            //Commit _user for user
            _context.SaveChanges();
            //Optionally, return the object
            return(_context.Users.Find(user.ID));
        }
Esempio n. 2
0
        public Board addBoard(Board board, User user)
        {
            BulletinContext _context = new BulletinContext();
            //Create the user in the context and add board
            User _user = _context.Users.Find(user.ID);

            _user.Boards.Add(item: board);

            //save changes
            _context.SaveChanges();
            return(_context.Boards.Find(board.ID));
        }
Esempio n. 3
0
        public Post addPost(Board board, User user, Post post)
        {
            BulletinContext _context = new BulletinContext();
            //Create the board in the context and add post
            Board _board = _context.Boards.Find(board.ID);

            _board.Posts.Add(item: post);
            //Create the user in the context and add the post
            User _user = _context.Users.Find(user.ID);

            _user.Posts.Add(item: post);
            //save changes
            _context.SaveChanges();
            return(_context.Posts.Find(post.ID));
        }