Esempio n. 1
0
        public async Task <IActionResult> GetSession(string id)
        {
            try
            {
                var session = await _sessionsRepository.GetSession(Guid.Parse(id));

                return(Ok(session));
            }
            catch (Exception ex)
            {
                return(HandleError(ex));
            }
        }
Esempio n. 2
0
        private object Execute(IEventPublisher eventPublisher, ISessionsRepository sessionsRepository, LogOutUser command)
        {
            var session = sessionsRepository.GetSession(command.SessionId);

            session.Logout(eventPublisher);

            return(Negotiate.WithStatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 3
0
        public async Task <IHttpActionResult> GetLockedLicenses()
        {
            try
            {
                var token   = GetHeaderSessionToken();
                var session = await _sessions.GetSession(Session.Convert(token));

                if (session == null)
                {
                    return(Unauthorized());
                }

                var licenses = await _repo.GetLockedLicenses(session.UserId, session.LicenseLevel, WebApiConfig.LicenseHoldTime);

                var response = Request.CreateResponse(HttpStatusCode.OK,
                                                      new LicenseInfo {
                    LicenseLevel = session.LicenseLevel, Count = licenses
                });

                return(ResponseMessage(response));
            }
            catch (ArgumentNullException)
            {
                return(Unauthorized());
            }
            catch (FormatException)
            {
                return(Unauthorized());
            }
            catch (Exception ex)
            {
                await _log.LogError(WebApiConfig.LogSourceLicenses, ex);

                return(InternalServerError());
            }
        }