public IActionResult Put(int id, ConferenceDTO.Session input) { var session = _db.Sessions.FindAsync(id) .GetAwaiter() .GetResult(); if (session == null) { return(NotFound()); } session.ID = input.ID; session.Title = input.Title; session.Abstract = input.Abstract; session.StartTime = input.StartTime; session.EndTime = input.EndTime; session.TrackId = input.TrackId; session.ConferenceID = input.ConferenceID; _db.SaveChangesAsync() .GetAwaiter() .GetResult(); return(NoContent()); }
public async Task <ActionResult <SessionResponse> > Post(ConferenceDTO.Session input) { var session = new Data.Session { Title = input.Title, StartTime = input.StartTime, EndTime = input.EndTime, Abstract = input.Abstract, TrackId = input.TrackId }; _context.Sessions.Add(session); await _context.SaveChangesAsync(); var result = session.MapSessionResponse(); return(CreatedAtAction(nameof(Get), new { id = result.Id }, result)); }
public async Task <IActionResult> Put(int id, ConferenceDTO.Session input) { var session = await _context.Sessions.FindAsync(id); if (session == null) { return(NotFound()); } session.Id = input.Id; session.Title = input.Title; session.Abstract = input.Abstract; session.StartTime = input.StartTime; session.EndTime = input.EndTime; session.TrackId = input.TrackId; await _context.SaveChangesAsync(); return(NoContent()); }
public ActionResult <SessionResponse> Post(ConferenceDTO.Session input) { var session = new Data.Session { Title = input.Title, ConferenceID = input.ConferenceID, StartTime = input.StartTime, EndTime = input.EndTime, Abstract = input.Abstract, TrackId = input.TrackId }; _db.Sessions.Add(session); _db.SaveChangesAsync() .GetAwaiter() .GetResult(); var result = session.MapSessionResponse(); return(CreatedAtAction(nameof(Get), new { id = result.ID }, result)); }