示例#1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Appntmnt appntmnt = db.Appntmnt.Find(id);

            db.Appntmnt.Remove(appntmnt);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#2
0
        // GET: Appntmnts/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Appntmnt appntmnt = db.Appntmnt.Find(id);

            if (appntmnt == null)
            {
                return(HttpNotFound());
            }
            return(View(appntmnt));
        }
示例#3
0
        public ActionResult Create([Bind(Include = "Appntmnt_ID,StudentUserID,Appntmnt_Date,Appntmnt_Time")] Appntmnt appntmnt)
        {
            GetCurrentUserInViewBag();
            ViewBag.StudentUserID = new SelectList(db.Students, "UserID", "StudentID");
            var currentUserId = User.Identity.GetUserId();
            var app           = db.Appntmnt.FirstOrDefault(d => d.StudentUserID == currentUserId);
            var u             = db.Students.FirstOrDefault(d => d.UserID == currentUserId);
            var a             = db.Counsellor.FirstOrDefault(d => d.CounsellorEmail == currentUserId);

            if (ModelState.IsValid)
            {
                db.Appntmnt.Add(appntmnt);
                db.SaveChanges();
                TempData["Message"] = "User: "******", has set a date for Counselling";

                try
                {
                    //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 = "******";

                    //Sender email address.
                    WebMail.From = u.StudentEmail;

                    //Send email
                    WebMail.Send(to: a.CounsellorEmail, subject: u.StudentFirstName + " " + u.StudentLastName + "  Appointment Schedule", body: "Date: " + app.Appntmnt_Date + "Time: " + app.Appntmnt_Time, isBodyHtml: true);
                    ViewBag.Status      = "Email Sent Successfully.";
                    TempData["Message"] = "User: "******", Email Sent";
                }
                catch (Exception)
                {
                    ViewBag.Status = "Problem while sending email, Please check details.";
                }

                return(RedirectToAction("Index", "Home"));
            }

            ViewBag.StudentUserID = new SelectList(db.Students, "UserID", "StudentID", appntmnt.StudentUserID);
            return(View(appntmnt));
        }
示例#4
0
        public ActionResult Edit([Bind(Include = "Appntmnt_ID,StudentUserID,Appntmnt_Date,Appntmnt_Time")] Appntmnt appntmnt)
        {
            GetCurrentUserInViewBag();
            ViewBag.StudentUserID = new SelectList(db.Students, "UserID", "StudentID");
            var currentUserId = User.Identity.GetUserId();
            var app           = db.Appntmnt.FirstOrDefault(d => d.StudentUserID == currentUserId);
            var u             = db.Students.FirstOrDefault(d => d.UserID == currentUserId);
            var a             = db.Counsellor.FirstOrDefault(d => d.CounsellorEmail == currentUserId);

            if (ModelState.IsValid)
            {
                db.Entry(appntmnt).State = EntityState.Modified;
                db.Appntmnt.Add(appntmnt);
                try
                {
                    db.SaveChanges();
                    //Configuring webMail class to send emails
                    //gmail smtp server  C:\Users\Alyssa\Source\Repos\MMCCIS-v3\Testv3\Controllers\AppntmntsController.cs
                    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 = "******";

                    //Sender email address.
                    WebMail.From = a.CounsellorEmail;

                    //Send email
                    WebMail.Send(to: u.StudentEmail, subject: "Message from MMCIS Counsellor " + a.CounsellorEmail, body: "Date: " + app.Appntmnt_Date + "Time: " + app.Appntmnt_Time, isBodyHtml: true);
                    TempData["Message"] = "User: "******", Email Sent";
                }

                catch (Exception)
                {
                    ViewBag.Status = "Problem while rescheduling, Please check details.";
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.StudentUserID = new SelectList(db.Students, "UserID", "StudentID", appntmnt.StudentUserID);
            return(View(appntmnt));
        }
示例#5
0
        public ActionResult Submit(int?id)
        {
            GetCurrentUserInViewBag();
            ViewBag.StudentUserID = new SelectList(db.Students, "UserID", "StudentID");
            var currentUserId = User.Identity.GetUserId();
            var app           = db.Appntmnt.FirstOrDefault(d => d.StudentUserID == currentUserId);
            var u             = db.Students.FirstOrDefault(d => d.UserID == currentUserId);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Appntmnt appntmnt = db.Appntmnt.Find(id);

            if (appntmnt == null)
            {
                return(HttpNotFound());
            }
            return(View(appntmnt));
        }