private MailMessage GenerateMessage(int reviewId, Event evt)
        {
            MailMessage message;

            try
            {
                var session = _reviewRepository.Get(reviewId);
                var account = _accountRepository.GetByName(session.Reviewer);

                var args = new NotificationArgs
                {
                    BaseUrl     = ConfigurationManager.AppSettings["WebUrl"],
                    DisplayName = account.ScreenName,
                    Recipient   = account.EmailAddress,
                    SessionId   = reviewId.ToString(),
                    SessionName = session.Title
                };

                message      = _generator.Generate(evt.EventType, args);
                evt.Recevied = true;
            }
            catch (Exception ex)
            {
                string test = ex.Message;
                throw;
            }

            return(message);
        }
        public IActionResult Index()
        {
            var user = GetUser();

            user = _repository.Get(x => user.Id == x.Id).Include(x => x.TransportTables).ToList()[0];
            return(View(user.TransportTables));
        }
Exemple #3
0
        /// <summary>
        /// If the ‘username’ exists, assigns the reviewer’s username to the session in the system. If not, triggers an event
        /// which will send out an email to invite a new reviewer to register an account with the system.
        /// </summary>
        /// <remarks>
        /// The event persist the session id for which the new user will be assign as a reviewer.
        /// This will be used by the Account Monitor to assign the new reviewer’s username to the session in the system.
        /// </remarks>
        /// <param name="reviewer">The username of the reviewer</param>
        /// <param name="sessionId">The id of the review session</param>
        /// <param name="current">The API user's username</param>
        /// <exception cref="SessionNotFoundException"></exception>
        /// <exception cref="AuthorizationException"></exception>
        /// <exception cref="InvalidOperationException"></exception>
        public void AssignReviewer(int sessionId, string reviewer, string current)
        {
            var session = _sessionRepository.Get(sessionId);

            if (session == null)
            {
                throw new SessionNotFoundException();
            }

            if (session.PendingReviewer)
            {
                throw new InvalidOperationException();
            }

            if (session.Creator.ToLower() != current.ToLower())
            {
                throw new AuthorizationException();
            }

            session.Reviewer = reviewer;
            _sessionRepository.Save(session);

            var assignEvent = new Event
            {
                Created   = DateTime.UtcNow,
                EntityId  = session.Id,
                EventType = EventType.ReviewerAssigned,
                Info      = new Dictionary <string, string> {
                    { "username", reviewer }
                }
            };

            _eventRepository.Save(assignEvent);
        }
        public void Delete(int id)
        {
            var account = _repository.Get(id);

            _repository.Delete(account);
        }