示例#1
0
 public IHttpActionResult CreateSession(SessionModel sessionModel)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         SessionDTO session = _mapper.Map <SessionDTO>(sessionModel);
         _sessionService.CreateSession(session);
         return(Ok("Session was created"));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
示例#2
0
 public IHttpActionResult GetAllSessions()
 {
     try
     {
         IEnumerable <SessionDTO> sessionsDTO = _sessionService.GetAllSessions();
         List <SessionModel>      sessions    = new List <SessionModel>();
         foreach (SessionDTO s in sessionsDTO)
         {
             SessionModel sess = _mapper.Map <SessionModel>(s);
             sessions.Add(sess);
         }
         return(Ok(sessions));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }