public async Task <ActionResult> UpdateSessionStatus(int Id, string Name, string UserId = "") { try { if (Name == "Delete") { await _tutorService.DeleteSession(Id); } else { if (string.IsNullOrEmpty(UserId) || UserId == "0") { UserId = User.Identity.GetUserId(); } var result = await _tutorService.ApproveDeclineSession(Id, new Sessions() { Status = Name == "Approve" ? SessionStatus.Approved : SessionStatus.Declined, ApproveDeclineBy = UserId }); if (result.Item1) { try { var _session = result.Item2; var _status = Name == "Approve" ? "Aprroved" : "Declined"; var _subject = _status + " Session Request | instanttutors.org"; var _body = "<h3>Session request has been " + _status + ".</h3>" + "<b>Session Title:</b> " + _session.Title + "<br/>" + "<b>Description <small>(If Any)</small>:</b> " + _session.Description + "<br/>" + "<b>Communication Method:</b> " + _session.CommunicationMethod + "<br/><br/>" + "<a href='http://instanttutors.org/' target='_blank'>Instant Tutors</a> Team @" + DateTime.Now.Year; await EmailSender.SendEmailAsync(_subject, _body); await SMSSender.SMSSenderAsync(_session.Title + " Session request has been " + _status + "."); } catch (Exception ex1) { } } } } catch (Exception ex) { } return(RedirectToAction("Index")); }
public async Task <ActionResult> Availability(TutorViewModel model) { if (ModelState.IsValid) { try { await _tuitionService.SetAvailabilityAsync(model); ModelState.Clear(); ViewBag.success = "<ul><li><p style='color:green'>Successfully Submitted!! Thanks for providing information.</p></li></ul>"; var t = Task.Run(() => { try { var _subject = "Tuition Availability - " + model.User.FirstName + " " + model.User.LastName + " | instanttutors.org"; var _body = "<b>Tutor Availability Updation</b><br><br/> " + "Tutor : <b>" + model.User.FirstName + " " + model.User.LastName + "</b><br/>" + "Tutor has updated Tuition Availability Information. <br/>" + "Comment/Concerns: " + model.Concerns + "<br/><br/>" + "<a href='http://instanttutors.org/' target='_blank'>Instant Tutors</a> @ " + DateTime.Now.Year; EmailSender.SendEmail(_subject, _body); SMSSender.SMSSenderAsync("Tutor " + model.User.FirstName + " " + model.User.LastName + " just updated tuition availability time."); } catch { } }); return(View(model)); } catch (Exception ex) { ViewBag.success = "<ul><li><p style='color:red'>ERROR: " + ex.Message + "</p></li></ul>"; return(View(model)); } } else { var error = ModelState.FirstOrDefault(x => x.Value.Errors.Count > 0).Value.Errors.First().ErrorMessage; ViewBag.success = "<ul><li><p style='color:red'>ERROR: " + error + "</p></li></ul>"; } return(View(model)); }
public async Task <JsonResult> UpdateSessionStatus(int SessionId, string UserId, SessionStatus status) { if (string.IsNullOrEmpty(UserId) || UserId == "0") { UserId = User.Identity.GetUserId(); } var result = await _tutorService.ApproveDeclineSession(SessionId, new Sessions() { Status = status, ApproveDeclineBy = UserId }); if (result.Item1) { try { var _session = result.Item2; var _status = _session.Status == SessionStatus.Approved ? "Aprroved" : "Declined"; var _subject = status + " Session Request | instanttutors.org"; var _body = "<h3>Session request has been " + _status + ".</h3>" + "<b>Session Title:</b> " + _session.Title + "<br/>" + "<b>Description <small>(If Any)</small>:</b> " + _session.Description + "<br/>" + "<b>Communication Method:</b> " + _session.CommunicationMethod + "<br/><br/>" + "<a href='http://instanttutors.org/' target='_blank'>Instant Tutors</a> Team @" + DateTime.Now.Year; await EmailSender.SendEmailAsync(_subject, _body); await SMSSender.SMSSenderAsync(_session.Title + " Session request has been " + _status + "."); } catch (Exception ex1) { } } return(Json(result.Item1, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> Schedule(AdminSessionViewModel model) { int insertedID = 0; if (ModelState.IsValid) { try { var sessionInfo = string.Empty; int DayTimeChecked = 0; if (model.SessionSchedules != null) { foreach (var schedule in model.SessionSchedules) { foreach (var time in schedule.Timing) { if (time.Selected) { DayTimeChecked += 1; sessionInfo += "<b>" + schedule.Day.ToString() + "</b> <b>" + time.Time + "</b> <b>" + model.CommunicationMethod + "</b> <b>(" + model.Title + ")</b><br/><br/>"; } } } } if (DayTimeChecked < 2) { ViewBag.success = "<ul><li><p style='color:red'>Validation ERROR: Please choose atleast 2+ Days/Times that you are available.</p></li></ul>"; model.Tutors = GetTutors(); return(View("NewSchedule", model)); } var message = "New Session has been scheduled."; if (model.Id > 0) { (bool success, AdminSessionViewModel data) = await _scheduleService.UpdateScheduleAsync(model); insertedID = data.Id; if (success == false) { ViewBag.success = "<ul><li><p style='color:red'>ERROR: Session Doesn't Exist.</p></li></ul>"; model.Tutors = GetTutors(); return(View("NewSchedule", model)); } message = "A scheduled session has been updated."; } else { (bool success, AdminSessionViewModel data) = await _scheduleService.CreateScheduleAsync(model); insertedID = data.Id; } var t = Task.Run(() => { try { var _subject = "Student Session Schedule Info - " + model.User.FirstName + " " + model.User.LastName + " | instanttutors.org"; var _body = "<a class='navbar-brand' href='/'><img src='http://www.instanttutors.org/Content/images/logo.png' style='width:240px;' /></a>"; _body += "<p>Greetings,</p>"; _body += "<p>" + model.Title.ToUpper() + "</p>"; _body += "<p>Student: " + model.User.FirstName + " " + model.User.LastName + " is requesting a session for the following days</p>"; _body += "<p><span style='text - decoration: underline;'>AVAILABLE ON :</span></p>"; _body += "<p>" + sessionInfo + "</p>"; _body += "<p>if you would like to approve it click the below link.</p>"; _body += "<p>"; _body += "<a href='" + ConfigurationManager.AppSettings["SiteURL"] + "?action=approve&code=SGEnYsdguwwhXuGurbIVrr2UviISKcPAFJwJm9e93MsygYBk60sxU1qH%&id=" + insertedID + "'>" + "'" + ConfigurationManager.AppSettings["SiteURL"] + "?action=approve&code=SGEnYsdguwwhXuGurbIVrr2UviISKcPAFJwJm9e93MsygYBk60sxU1qH%&id=" + insertedID + "'</p>"; _body += "<p>if you would like to decline the tutor request, you can click the below link :</p>"; _body += "<a href=" + ConfigurationManager.AppSettings["SiteURL"] + "?action=decline&code=SGEnYsdguwwhXuGurbIVrr2UviISKcPAFJwJm9e93MsygYBk60sxU1qH%&id=" + insertedID + ">" + "'" + ConfigurationManager.AppSettings["SiteURL"] + "?action=decline&code=SGEnYsdguwwhXuGurbIVrr2UviISKcPAFJwJm9e93MsygYBk60sxU1qH%&id=" + insertedID + "'</p>"; _body += "<p>--</p>"; _body += "<p>Regards from <a href='http://instanttutors.org/' target='_blank' rel='noopener'>Intant Tutors Team</a> </p>"; _body += "<p> </p>"; string emailTo = utilityService.GetEmailAddress(model.Student); string emailTo1 = utilityService.GetEmailAddress(model.Tutor); EmailSender.SendEmailAdmin(_subject, _body, emailTo, emailTo1); SMSSender.SMSSenderAsync(message + " Student name is " + model.User.FirstName + " " + model.User.LastName); } catch { } }); ModelState.Clear(); ViewBag.success = "<div class='alert alert-success'><strong>Success!</strong> " + message + "</div>"; var _user = await UserManager.FindByEmailAsync(User.Identity.Name); StudentViewModel _studentViewModel = new StudentViewModel() { UserId = _user.Id, User = _user }; _studentViewModel.SessionsList = await _sessionService.GetSessionAdminAsync(_user.Id); return(View("Index1", _studentViewModel)); //return View("SelectTiming", model); } catch (Exception ex) { ViewBag.success = "<div class='alert alert-danger'><strong>ERROR!</strong> " + ex.Message + ".</div>"; model.Tutors = GetTutors(); model.Students = GetStudents(); return(View("NewSchedule", model)); } } model.Tutors = GetTutors(); model.Students = GetStudents(); return(View("NewSchedule", model)); }
public async Task <ActionResult> Student(StudentRegisterViewModel model, HttpPostedFileBase file) { if (ModelState.IsValid) { var _existUser = await UserManager.FindByEmailAsync(model.Email); if (_existUser != null) { ViewBag.Message = "Email Already Exists."; ModelState.AddModelError("", "Email Already Exists."); return(View(model)); } //profile upload //if (file != null) //{ // var supportedTypes = new[] { "jpg", "jpeg", "png", "gif" }; // var fileExt = System.IO.Path.GetExtension(file.FileName).Substring(1); // //if ((file.ContentLength / 1024 > 1024) || (!supportedTypes.Contains(fileExt))) // //{ // // ViewBag.Message = "Only JPEG/PNG image smaller than 1MB is allowed."; // // ModelState.AddModelError("", "Only JPEG/PNG image smaller than 1MB is allowed."); // // return View(model); // //} // if (supportedTypes.Contains(fileExt)) // { // var profileImage = Guid.NewGuid() + Path.GetExtension(file.FileName); // file.SaveAs(HttpContext.Server.MapPath("~/Content/images/student/") + profileImage); // model.ProfileImage = profileImage; // } //} //profile upload if (model.File != null) { try { var supportedTypes = new[] { "jpg", "jpeg", "png", "gif", "tif" }; var fileExt = System.IO.Path.GetExtension(model.File.FileName).Substring(1); if (supportedTypes.Contains(fileExt.ToLower())) { var profileImage = Guid.NewGuid() + Path.GetExtension(model.File.FileName); model.File.SaveAs(HttpContext.Server.MapPath("~/Content/images/student/") + profileImage); model.ProfileImage = profileImage; } } catch (Exception exi) { } } var user = new ApplicationUser { UserName = model.Email, Email = model.Email, Gender = model.Gender, FirstName = model.FirstName, LastName = model.LastName, PhoneNumber = model.Mobile, Address = model.Address, City = model.City, TimeZone = model.TimeZone, Country = model.Country, Zip = model.Zip, Bio = model.Bio, StudentSchool = model.StudentSchool, StudentGrade = model.StudentGrade, Hobbies = model.Hobbies, ProfileImage = model.ProfileImage, //DOB = DateTime.Now.AddYears(-29), CreatedDate = DateTime.Now, //UpdatedDate = DateTime.Now }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { UserManager.AddToRole(user.Id, "Student"); //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); // Send an email with this link string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Hi " + model.FirstName + ",<br/><br/>" + "Thanks for registering with us.<br/>" + "Please confirm your student account by clicking <a href=\"" + callbackUrl + "\">" + callbackUrl + "</a><br/><br/>" + "Regards, <br/><a href='http://instanttutors.org/' target='_blank'>Instant Tutors Team</a>"); //await EmailSender.SendEmailAsync("Confirm your account", "Hi " + model.FirstName + ",<br/><br/>" // + "Thanks for registering with us.<br/>" // + "Please confirm your student account by clicking <a href=\"" + callbackUrl + "\">" + callbackUrl + "</a><br/><br/>" // + "Regards, <br/><a href='http://instanttutors.org/' target='_blank'>Instant Tutors @" + DateTime.Now.Year + "</a>", user.Email, true); try { var _subject = "New Student Signup | instanttutors.org"; var _body = "<h5>New Student Signup</h5>" + ",<br/><br/>" + "<b>Fullname:</b> " + model.FirstName + " " + model.LastName + "<br/>" + "<b>Email Address:</b> " + model.Email + "<br/>" + "<b>Mobile:</b> " + model.Mobile + "<br/><br/>" + "<a href='http://instanttutors.org/' target='_blank'>Instant Tutors</a> @ " + DateTime.Now.Year; await EmailSender.SendEmailAsync(_subject, _body); await SMSSender.SMSSenderAsync("Thanks! Please verify your student a/c " + callbackUrl + " <br>Instant Tutors Team", user.PhoneNumber); //await SMSSender.SMSSenderAsync("New Student Registration - Name: " + user.FirstName + " " + user.LastName + ", M: " + user.PhoneNumber + ", Email: " + user.Email); } catch { } ModelState.Clear(); ViewBag.success = "<ul><li><p style='color:green'>Successfully registered!! An email has been sent to your email address, Please verify.</p></li></ul>"; return(View(model)); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <ActionResult> Tutor(TutorRegisterViewModel model) { if (ModelState.IsValid) { var _existUser = await UserManager.FindByEmailAsync(model.Email); if (_existUser != null) { await UserManager.UpdateAsync(_existUser); ViewBag.Message = "Email Already Exists."; ModelState.AddModelError("", "Email Already Exists."); return(View(model)); } //profile upload if (model.File != null) { //var supportedTypes = new[] { "jpg", "jpeg", "png", "gif" }; //var fileExt = System.IO.Path.GetExtension(model.File.FileName).Substring(1); try { var supportedTypes = new[] { "jpg", "jpeg", "png", "gif", "tif" }; var fileExt = System.IO.Path.GetExtension(model.File.FileName).Substring(1); if (supportedTypes.Contains(fileExt.ToLower())) { var profileImage = Guid.NewGuid() + Path.GetExtension(model.File.FileName); model.File.SaveAs(HttpContext.Server.MapPath("~/Content/images/tutor/") + profileImage); model.ProfileImage = profileImage; } } catch (Exception exi) { } } var user = new ApplicationUser { UserName = model.Email, Email = model.Email, Title = model.Title, Gender = model.Gender, FirstName = model.FirstName, LastName = model.LastName, PhoneNumber = model.Mobile, Address = model.Address == null ? model.City + " " + model.Country + " " + model.Zip : model.Address, City = model.City, TimeZone = model.TimeZone, Country = model.Country, Zip = model.Zip, Bio = model.Bio, //summary Hobbies = model.Hobbies, ProfileImage = model.ProfileImage, //DOB = DateTime.Now.AddYears(-29), CreatedDate = DateTime.Now, //UpdatedDate = DateTime.Now }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { UserManager.AddToRole(user.Id, "Tutor"); var __tutor = await this._accountService.CreateTutorsAsync(new Tutors { UserId = user.Id, Experience = model.Experience, GradeLevel = model.GradeLevel, NameOfSchool = model.GradeLevel, //Concerns PreviousSubjects = model.GradeLevel }); try { if (model.TuitionSubjects != null && __tutor.Id > 0) { await this._accountService.AddTutorSubjectAsync(model.TuitionSubjects, __tutor.Id); } } catch (Exception ex) { } //await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); // Send an email with this link string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Hi " + model.FirstName + ",<br/><br/>" + "Thanks for registering with us.<br/>" + "Please confirm your tutor account by clicking <a href=\"" + callbackUrl + "\">" + callbackUrl + "</a><br/><br/>" + "Regards, <br/><a href='http://instanttutors.org/' target='_blank'>Instant Tutors Team</a>"); //await EmailSender.SendEmailAsync("Confirm your account", "Hi " + model.FirstName + ",<br/><br/>" // + "Thanks for registering with us.<br/>" // + "Please confirm your student account by clicking <a href=\"" + callbackUrl + "\">" + callbackUrl + "</a><br/><br/>" // + "Regards, <br/><a href='http://instanttutors.org/' target='_blank'>Instant Tutors @" + DateTime.Now.Year + "</a>", user.Email, true); try { var _subject = "New Tutor Signup | instanttutors.org"; var _body = "<h5>New Tutor Signup</h5>" + ",<br/><br/>" + "<b>Fullname:</b> " + model.FirstName + " " + model.LastName + "<br/>" + "<b>Email Address:</b> " + model.Email + "<br/>" + "<b>Mobile:</b> " + model.Mobile + "<br/><br/>" + "<a href='http://instanttutors.org/' target='_blank'>Instant Tutors</a> @ " + DateTime.Now.Year; await EmailSender.SendEmailAsync(_subject, _body); await SMSSender.SMSSenderAsync("Thanks! Please verify your tutor a/c " + callbackUrl + " <br>Instant Tutors Team", user.PhoneNumber); await SMSSender.SMSSenderAsync("New Tutor Registration - Name: " + user.FirstName + " " + user.LastName + ", M: " + user.PhoneNumber + ", Email: " + user.Email); } catch { } ModelState.Clear(); ViewBag.success = "<ul><li><p style='color:green'>Successfully registered!! An email has been sent to your email address, Please verify.</p></li></ul>"; return(View(model)); } AddErrors(result); } //var error = ModelState.FirstOrDefault(x => x.Value.Errors.Count > 0).Value.Errors.First().ErrorMessage; // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <ActionResult> Schedule(SessionViewModel model) { model.TutorsList = model.TutorsList == null ? await _sessionService.GetTutorsAsync() : model.TutorsList; if (ModelState.IsValid) { try { var sessionInfo = string.Empty; int DayTimeChecked = 0; if (model.SessionSchedules != null) { foreach (var schedule in model.SessionSchedules) { foreach (var time in schedule.Timing) { if (time.Selected) { DayTimeChecked += 1; sessionInfo += "<b>" + schedule.Day.ToString() + "</b> <b>" + time.Time + "</b> <b>" + model.CommunicationMethod + "</b> <b>(" + model.Title + ")</b><br/><br/>"; } } } } if (DayTimeChecked < 2) { ViewBag.success = "<ul><li><p style='color:red'>Validation ERROR: Please choose atleast 2+ Days/Times that you are available.</p></li></ul>"; return(View(model)); } var message = "New Session has been scheduled."; try { model.CreatedBy = User.Identity.GetUserId(); } catch { } if (model.Id > 0) { (bool success, SessionViewModel data) = await _scheduleService.UpdateScheduleAsync(model); if (success == false) { ViewBag.success = "<ul><li><p style='color:red'>ERROR: Session Doesn't Exist.</p></li></ul>"; return(View(model)); } message = "A scheduled session has been updated."; } else { (bool success, SessionViewModel data) = await _scheduleService.CreateScheduleAsync(model); } //var t = Task.Run(() => //{ try { var tutorInfo = await UserManager.FindByIdAsync(model.TutorUserId); var _subject = "New Session Scheduled - " + model.User.FirstName + " " + model.User.LastName + " | instanttutors.org"; var _body = "<h3>" + message + "</h3>" + "<b>Student Name:</b> " + model.User.FirstName + " " + model.User.LastName + "<br/>" + "<b>Email:</b> " + model.User.Email + "<br/>" + "<b>Mobile:</b> " + model.User.PhoneNumber + "<br/>" + "<b>Session Title:</b> " + model.Title + "<br/>" + "<b>Description <small>(If Any)</small>:</b> " + model.Description + "<br/>" + "<b>Tutor Information:</b> " + tutorInfo.FirstName + " " + tutorInfo.LastName + " <small>(" + tutorInfo.Gender + ")</small>, E: " + tutorInfo.Email + ", M: " + tutorInfo.PhoneNumber + "<br/>" + "<b>Communication Method:</b> " + model.CommunicationMethod + "<br/>" + "<b>Comment/Concerns <small>(If Any)</small>:</b> " + model.Concerns + "<h4>AVAILABLE ON : </h4>" + sessionInfo + "<br/><br/>" + "<a href='http://instanttutors.org/' target='_blank'>Instant Tutors</a> Team @" + DateTime.Now.Year; await EmailSender.SendEmailAsync(_subject, _body); await SMSSender.SMSSenderAsync(message + " Student name is " + model.User.FirstName + " " + model.User.LastName); } catch (Exception ex1) { } //}); ModelState.Clear(); ViewBag.success = "<ul><li><p style='color:green'>Hurray!! Session info successfully submitted.</p></li></ul>"; return(View(model)); } catch (Exception ex) { ViewBag.success = "<ul><li><p style='color:red'>ERROR: " + ex.Message + "</p></li></ul>"; return(View(model)); } } return(View(model)); }