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)); }
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)); }
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)); }