private IList <ErrorStatus> Validate(GetItemRequest request) { var errors = new List <ErrorStatus>(); if (string.IsNullOrEmpty(request.Ticket)) { errors.Add(new ErrorStatus("INVALID_TICKET")); return(errors); } if (request.ItemId == null || request.ItemId <= 0) { errors.Add(new ErrorStatus("BAD_REQUEST")); return(errors); } var user = _userSessionRepository.GetUserBySessionId(request.Ticket); var userOwner = _itemRepository.GetUserByItemId(request.ItemId); if (user == null || userOwner == null) { errors.Add(new ErrorStatus("USER_NOT_FOUND")); return(errors); } if (user.Id != userOwner.Id) { errors.Add(new ErrorStatus("UNAUTHORIZED_ACESS")); } return(errors); }
public SessionInfo GetSessionInfo(string ticket) { var session = _userSessionRepository.GetSession(ticket); if (session == null || session.Expires < DateTime.Now) { return(null); } var user = _userSessionRepository.GetUserBySessionId(ticket); var sessionInfo = new SessionInfo { User = user, Session = session }; return(sessionInfo); }