public void Add(BrainstormSession session) { int maxId = 0; if (_dbContext.BrainstormSessions.Any()) { maxId = _dbContext.BrainstormSessions.Max(s => s.Id); } session.Id = maxId + 1; _dbContext.BrainstormSessions.Add(session); _dbContext.SaveChanges(); }
public static BrainstormSession GetTestSession() { var session = new BrainstormSession() { Name = "Test Session 1", DateCreated = new DateTime(2016, 8, 1) }; var idea = new Idea() { DateCreated = new DateTime(2016, 8, 1), Description = "Totally awesome idea", Name = "Awesome idea" }; session.AddIdea(idea); return session; }
public void Update(BrainstormSession session) { _dbContext.Entry(session).State = EntityState.Modified; _dbContext.SaveChanges(); }
private BrainstormSession GetTestSession() { var session = new BrainstormSession() { DateCreated = new DateTime(2016, 7, 2), Id = 1, Name = "Test One" }; var idea = new Idea() { Name = "One" }; session.AddIdea(idea); return session; }
public Task UpdateAsync(BrainstormSession session) { _dbContext.Entry(session).State = EntityState.Modified; return _dbContext.SaveChangesAsync(); }
public Task AddAsync(BrainstormSession session) { _dbContext.BrainstormSessions.Add(session); return _dbContext.SaveChangesAsync(); }