public async Task <ActionResult> SavePhoto() { byte[] byteArray; if (Session["dump"] == null) { return(RedirectToAction("Index", "Error", new { message = string.Format("Try capturing the image again") })); } byteArray = String_To_Bytes2(Session["dump"].ToString()); // Initialize the GraphServiceClient. GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient(); var userDetails = await eventsService.GetMyDetails(graphClient); var result = await filesService.CreateFile(graphClient, byteArray); try { CaptureNote captureNote = new CaptureNote() { CapturedDate = DateTime.Now, Email = Session["facultyMail"] != null ? Session["facultyMail"].ToString() : "", NoteLink = result.Display, StudentName = userDetails.DisplayName, }; try { db.captureNotes.Add(captureNote); var val = db.SaveChanges(); if (val != 0) { var path = Server.MapPath("~/WebImages/"); System.IO.DirectoryInfo di = new DirectoryInfo(path); foreach (FileInfo file in di.GetFiles()) { file.Delete(); } } } catch (RetryLimitExceededException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log.) ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); } } catch (ServiceException se) { if (se.Error.Message == Resource.Error_AuthChallengeNeeded) { return(new EmptyResult()); } // Personal accounts that aren't enabled for the Outlook REST API get a "MailboxNotEnabledForRESTAPI" or "MailboxNotSupportedForRESTAPI" error. return(RedirectToAction("Index", "Error", new { message = string.Format(Resource.Error_Message, Request.RawUrl, se.Error.Code, se.Error.Message) })); } return(RedirectToAction("Index", "Student").Success("Note captured successfully.")); }
public async Task <ActionResult> MessageView() { GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient(); User fac = await eventsService.GetMyDetails(graphClient); OfficeHoursContext officeHoursContext = new OfficeHoursContext(); List <StudentMessage> studentMessages = officeHoursContext.messages.ToList(); List <WebApp.Models.StudentMessage> messages = new List <StudentMessage>(); foreach (var st in studentMessages) { if (st.student_id.Equals(fac.Mail)) { messages.Add(st); } } return(View(messages)); }
// GET: StudentMessages public async Task <ActionResult> Index() { // Initialize the GraphServiceClient. GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient(); var userDetails = await eventsService.GetMyDetails(graphClient); if (Session["facultyMail"] != null) { List <StudentMessage> studentMessages = new List <StudentMessage>(); var messages = db.messages.ToList(); foreach (var msg in messages) { if (msg.student_id.Equals(userDetails.Mail)) { studentMessages.Add(msg); } } return(View(studentMessages)); } return(RedirectToAction("Home", "Home").Information("Please Select the faculty")); }
public async Task <ActionResult> Index() { if (Request.IsAuthenticated) { GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient(); var userDetails = await eventsService.GetMyDetails(graphClient); var hasFaculty = db.faculties.Select(q => q.Email).ToList().Contains(userDetails.Mail ?? userDetails.UserPrincipalName); if (hasFaculty) { Session["Role"] = "Faculty"; return(View()); } else { Session["Role"] = "Student"; return(RedirectToAction("Home")); } } return(RedirectToAction("Home")); }
public async Task <ActionResult> Create([Bind(Include = "Subject,EventDate,EventStart,EventEnd")] EventsItem eventsItem) { EventsItem results = new EventsItem(); // Initialize the GraphServiceClient. GraphServiceClient graphClient = SDKHelper.GetAuthenticatedClient(); var userDetails = await eventsService.GetMyDetails(graphClient); try { var subject = Request.Form["Subject"]; var eventDate = Request.Form["EventDate"]; var eventStartTime = Request.Form["EventStart"]; var eventEndTime = Request.Form["EventEnd"]; var eventdatetime = DateTime.Parse(eventDate); var startTimespan = DateTime.ParseExact(eventStartTime, "hh:mm tt", CultureInfo.InvariantCulture); var endTimespan = DateTime.ParseExact(eventEndTime, "hh:mm tt", CultureInfo.InvariantCulture); var s = eventsItem; OfficeSchedule officeSchedule = new OfficeSchedule { end_time = new DateTime(eventdatetime.Year, eventdatetime.Month, eventdatetime.Day, endTimespan.Hour, endTimespan.Minute, endTimespan.Second), start_time = new DateTime(eventdatetime.Year, eventdatetime.Month, eventdatetime.Day, startTimespan.Hour, startTimespan.Minute, startTimespan.Second), Subject = subject, Email = userDetails.Mail ?? userDetails.UserPrincipalName, }; //var mail = await eventsService.GetMyEmailAddress(graphClient); try { db.officeSchedule.Add(officeSchedule); db.SaveChanges(); } catch (RetryLimitExceededException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log.) ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator."); } results = new EventsItem() { Subject = subject, StartTime = new DateTimeTimeZone { DateTime = new DateTime(eventdatetime.Year, eventdatetime.Month, eventdatetime.Day, startTimespan.Hour, startTimespan.Minute, startTimespan.Second).ToString("o"), TimeZone = TimeZoneInfo.Local.Id }, EndTime = new DateTimeTimeZone { DateTime = new DateTime(eventdatetime.Year, eventdatetime.Month, eventdatetime.Day, endTimespan.Hour, endTimespan.Minute, endTimespan.Second).ToString("o"), TimeZone = TimeZoneInfo.Local.Id }, }; // Create the event. results = await eventsService.CreateEvent(graphClient, results); } catch (ServiceException se) { if (se.Error.Message == Resource.Error_AuthChallengeNeeded) { return(new EmptyResult()); } // Personal accounts that aren't enabled for the Outlook REST API get a "MailboxNotEnabledForRESTAPI" or "MailboxNotSupportedForRESTAPI" error. return(RedirectToAction("Index", "Error", new { message = string.Format(Resource.Error_Message, Request.RawUrl, se.Error.Code, se.Error.Message) })); } return(RedirectToAction("Index", "Events").Success("Event Created")); }