public Thread NewThread(Thread thread) { var newThread = _dbContext.Threads.Add(thread); _dbContext.SaveChanges(); return(_dbContext.Threads.Where(t => t.ThreadId == thread.ThreadId).FirstOrDefault()); }
public User Register(User newUser) { var newUser1 = _dbContext.Users.Add(newUser); // addd the new user to the Db _dbContext.SaveChanges(); // save the change. return(_dbContext.Users.FirstOrDefault(u => u.Username == newUser.Username)); // default is null }
/// <summary> /// This method will add a haiku line to the database and then return the /// newly create haiku line back /// </summary> /// <param name="haikuline"></param> /// <returns></returns> public HaikuLine SaveLine(HaikuLine haikuline) { var newLine = _dbContext.HaikuLines.Add(haikuline);//add the new line to the database _dbContext.SaveChanges(); return(_dbContext.HaikuLines.FirstOrDefault(h => h.HaikuLineId == haikuline.HaikuLineId)); }