示例#1
0
        public async Task <ActionResult <SessionResponse> > Post(KonferansDTO.Session input)
        {
            var session = new Backend.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));
        }
示例#2
0
        public async Task <IActionResult> Put(int id, KonferansDTO.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());
        }