public PartialViewResult MeetingDetails(int meetingID) { MeetingRepository mr = new MeetingRepository(); var meeting = mr.GetMeeting(meetingID); var user = mr.GetMeetingCreator(meetingID); var names = mr.GetMeetingParticipants(meetingID); var time = mr.GetConfirmedTime(meetingID); var model = new MeetingViewModels { Subject = meeting.Subject, Place = meeting.Place, Date = meeting.Date, Sender = user.FirstName + " " + user.LastName, Names = names, Time = time }; return(PartialView("_MeetingDetailsPartial", model)); }
public PartialViewResult CreateMeeting() { UserRepository ur = new UserRepository(); var list = ur.GetUserList(); List <string> names = new List <string>(); List <string> mails = new List <string>(); foreach (var v in list) { names.Add(v.LastName + ", " + v.FirstName); mails.Add(v.Email); } var model = new MeetingViewModels { Names = names, Mails = mails }; return(PartialView("_CreateMeetingPartial", Tuple.Create(model, new DateTime()))); }
public ActionResult CreatedMeetings(MeetingViewModels obj, string subject, string place, string date, string creatorMail, string reicevMail, List <string> times, List <string> mails) { //Configuring webMail class to send emails //gmail smtp server WebMail.SmtpServer = "smtp.gmail.com"; //gmail port to send emails WebMail.SmtpPort = 587; WebMail.SmtpUseDefaultCredentials = true; //sending emails with secure protocol WebMail.EnableSsl = true; //EmailId used to send emails from application WebMail.UserName = "******"; WebMail.Password = "******"; DataContext db = new DataContext(); UserRepository ur = new UserRepository(); MeetingRepository mr = new MeetingRepository(); var meetingModel = new Meeting { Subject = subject, Place = place, Date = date, }; var creator = ur.GetUserByEmail(creatorMail); var invitationModel = new Invitation { //Meeting = meetingModel, Date = DateTime.Now, MeetingID = meetingModel.MID, //ApplicationUser = creator, UserID = creator.Id, }; var f = db.Users.Single(x => x.Id == invitationModel.UserID); WebMail.From = f.Email; List <RecieveMeetingInvitation> RMInviteList = new List <RecieveMeetingInvitation>(); RecieveMeetingInvitation receiver = new RecieveMeetingInvitation(); string allTimes = ""; foreach (string time in times) { allTimes += time + "<br>"; } foreach (string mail in mails) { var RMInvite = new RecieveMeetingInvitation { InvitationID = invitationModel.IID, UserID = ur.GetUserByEmail(mail).Id }; RMInviteList.Add(RMInvite); var t = db.Users.Single(x => x.Id == RMInvite.UserID); string body = String.Format("Du är inbjuden till mötet på/i {0} den {1} med dessa tidsförslag : <br> {2} <br> Vänligen logga in på <a href = 'https://github.com/'>hemsidan</a> för att svara på inbjudan. <hr> Det här är en automatisk inbjudan från Informatiks webbtjänst. <br> Svara inte på detta mejl.", place, date, allTimes); WebMail.Send(from: f.Email, to: t.Email, subject: obj.Subject, body: body, isBodyHtml: true); } List <TimeSuggestion> timeList = new List <TimeSuggestion>(); List <TimeAnswer> timeAnswerList = new List <TimeAnswer>(); foreach (string time in times) { var timeSuggestionModel = new TimeSuggestion { MeetingID = meetingModel.MID, Suggestion = time }; foreach (string mail in mails) { var user = ur.GetUserByEmail(mail); var timeAnswerModel = new TimeAnswer { UserID = user.Id, TimeID = timeSuggestionModel.TID }; timeAnswerList.Add(timeAnswerModel); } timeList.Add(timeSuggestionModel); } mr.AddMeeting(meetingModel, invitationModel, RMInviteList, timeList, timeAnswerList); return(RedirectToAction("ViewMeetings")); }