Exemple #1
0
        public void UpdateMeeting(Meeting meeting, string teamPrticipants, string otherParticipants)
        {
            var met = Database.Meetings.FirstOrDefault(m => m.Id == meeting.Id);
            Database.ObjectContext.ApplyCurrentValues("Meetings", meeting);
            Database.SaveChanges();
            //var users =
            //   teamPrticipants.Trim().Split(' ').Select(int.Parse).Select(
            //       id => Database.Users.FirstOrDefault(u => u.Id == id));

            //var emails = otherParticipants.Trim().Split(' ').ToList();
        }
Exemple #2
-1
        public void AddMeeting(Meeting meeting, string userParticipants, string otherParticipants)
        {
            var ms = new MessageService();
            if (!String.IsNullOrEmpty(userParticipants))
            {
                var users =
                    userParticipants.Trim().Split(' ').Select(int.Parse).Select(
                        id => Database.Users.FirstOrDefault(u => u.Id == id));
                users.ToList().ForEach((user) =>
                                           {
                                               meeting.Participants.Add(user);
                                               ms.SendMeetingInvitation(user.Email, meeting);
                                           });
            }
            if (!string.IsNullOrEmpty(otherParticipants))
            {
                var emails = otherParticipants.Trim().Split(' ').ToList();
                foreach (var email in emails)
                {
                    var trygetUser = Database.Users.FirstOrDefault(u => u.Email == email);
                    if (trygetUser == null)
                    {
                        trygetUser = new User
                                         {
                                             Email = email,
                                             AccountType = UserAccountType.MeetingParticipant,
                                             PasswordHash = MD5.EncryptMD5(email)
                                         };
                        Database.Users.Add(trygetUser);
                        ms.SendMeetingInvitation(trygetUser.Email, meeting, false);
                    }
                    else
                        ms.SendMeetingInvitation(trygetUser.Email, meeting);

                    meeting.Participants.Add(trygetUser);
                }
            }
            Database.Meetings.Add(meeting);
            Database.SaveChanges();
        }