Beispiel #1
0
        public async Task <ActionResult <SessionResponse> > Post(EventsDTO.Session input)
        {
            var session = new Data.Session
            {
                Title     = input.Title,
                StartTime = input.StartTime,
                EndTime   = input.EndTime,
                Abstract  = input.Abstract,
                TrackId   = input.TrackId
            };

            _db.Sessions.Add(session);
            await _db.SaveChangesAsync();

            var result = session.MapSessionResponse();

            return(CreatedAtAction(nameof(Get), new { id = result.Id }, result));
        }
Beispiel #2
0
        public async Task <IActionResult> Put(int id, EventsDTO.Session input)
        {
            var session = await _db.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 _db.SaveChangesAsync();

            return(NoContent());
        }