public async Task <ActionResult <SessionDto> > PostSession(SessionDto session) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } SessionDto sessionDto; try { sessionDto = await sessionService.CreateSessionAsync(session, User.Identity.Name); if (sessionDto != null) { this.RemoveCache(CacheKeys.Session); } } catch (Exception ex) { return(BadRequest(ex.Message)); } // var sessionDto = await _context.Sessions.Select(SessionDto.AsSessionDto).SingleOrDefaultAsync(m => m.Id == session.Id); return(CreatedAtAction("GetSession", new { id = sessionDto.Id }, sessionDto)); }