public async Task ChangeSession(Guid sessionId, UpdateSessionModel model)
        {
            var session = await _context.SessionSlots.FirstOrDefaultAsync(x => x.Id == sessionId);

            session.Start        = model.Start ?? session.Start;
            session.End          = model.End ?? session.End;
            session.Subjects     = model.Subjects ?? session.Subjects;
            session.MaxAttendees = model.MaxAttendees ?? session.MaxAttendees;
            session.Description  = model.Description ?? session.Description;

            _context.SessionSlots.Update(session);
            await _context.SaveChangesAsync();
        }
예제 #2
0
        public async Task <IActionResult> ChangeDetails([FromBody] UpdateSessionModel model, Guid sessionId)
        {
            if (!User.IsInRole("Admin") && (await _sessionService.GetSessionById(sessionId)).HostId == userId)
            {
                return(Unauthorized());
            }

            try
            {
                await _sessionService.ChangeSession(sessionId, model);

                return(Ok(new { message = "" }));
            }
            catch (AppException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }