Пример #1
0
        private async Task sendMeetingUpdateMail(Meeting meeting)
        {
            List <Invitation> invitations = InvitationRepository.GetMeeting(meeting.Id);

            if (invitations.Count > 0)
            {
                foreach (Invitation invitation in invitations)
                {
                    if (invitation.Status == 1)
                    {
                        Email mail = new Email();
                        mail.Title     = "Meeting: " + meeting.Title + " have been updated!";
                        mail.Text      = "The time for the meeting " + meeting.Title + " has been finalized.\n The new time is " + meeting.ConfirmedTime.ToString() + ".";
                        mail.Recipient = invitation.User.Email;
                        await MailService.Mail(mail);
                    }
                }
            }
        }
Пример #2
0
        public ActionResult Profile(int?id)
        {
            try
            {
                int     id2     = Convert.ToInt32(id);
                Meeting meeting = MeetingRepository.Get(id2);
                var     model   = new MeetingViewModel();
                if (meeting.Times.Count > 0)
                {
                    foreach (var time in meeting.Times)
                    {
                        model.Times.Add(time);
                    }
                }
                List <int>        alreadyInvitedUserIds = new List <int>();
                List <Invitation> StatusZero            = new List <Invitation>();
                List <Invitation> StatusOne             = new List <Invitation>();
                List <Invitation> StatusTwo             = new List <Invitation>();
                List <Invitation> invitations           = InvitationRepository.GetMeeting(id2);
                if (invitations.Count > 0)
                {
                    foreach (Invitation invitation in invitations)
                    {
                        model.Invitations.Add(invitation);
                        alreadyInvitedUserIds.Add(invitation.User.Id);
                        if (invitation.User.Id == Convert.ToInt32(User.Identity.GetUserId()))
                        {
                            model.CurrentUsersInvitation = invitation;
                        }
                        if (invitation.Status == 0)
                        {
                            StatusZero.Add(invitation);
                        }
                        if (invitation.Status == 1)
                        {
                            StatusOne.Add(invitation);
                        }
                        if (invitation.Status == 2)
                        {
                            StatusTwo.Add(invitation);
                        }
                    }
                }
                ICollection <User> allUsers = UserRepository.Get();
                foreach (User user in allUsers)
                {
                    if (!alreadyInvitedUserIds.Contains(user.Id) && user.Id != meeting.Creator.Id && allUsers.Count > 0 && !user.Username.ToLower().Equals("admin"))
                    {
                        model.NotInvitedUsers.Add(new SelectListItem
                        {
                            Text  = user.Name,
                            Value = user.Id.ToString()
                        });
                    }
                }
                var allTimeChoices     = TimeChoiceRepository.Get();
                var currentUsersCoices = new List <int>();

                foreach (var choice in allTimeChoices)
                {
                    if (choice.User.Id == Convert.ToInt32(User.Identity.GetUserId()))
                    {
                        currentUsersCoices.Add(choice.Time.Id);
                    }
                }
                if (alreadyInvitedUserIds.Contains(Convert.ToInt32(User.Identity.GetUserId())))
                {
                    model.Invited = true;
                }
                else
                {
                    model.Invited = false;
                }
                var voteList = new List <int>();
                foreach (var time in meeting.Times)
                {
                    voteList.Add(TimeChoiceRepository.GetCount(time.Id));
                }
                model.VoteArray            = voteList.ToArray();
                model.Inactive             = meeting.Inactive;
                model.ConfirmedTime        = meeting.ConfirmedTime;
                model.AlreadySelectedTimes = currentUsersCoices;
                model.CurrentUserId        = Convert.ToInt32(User.Identity.GetUserId());
                model.MeetingId            = meeting.Id;
                model.Creator     = meeting.Creator;
                model.Title       = meeting.Title;
                model.Description = meeting.Description;
                model.StatusZero  = StatusZero;
                model.StatusOne   = StatusOne;
                model.StatusTwo   = StatusTwo;
                return(View(model));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                return(RedirectToAction("Index"));
            }
        }