public ActionResult CourseRegEdit([Bind(Include = "FormID,StudentPhone,SubjectCode,Subject,SemesterName")] CourseRegForm courseRegForm, Form form)
        {
            if (ModelState.IsValid)
            {
                CourseRegForm crf = db.CourseRegForms.Find(courseRegForm.FormID);
                Form          f   = db.Forms.Find(courseRegForm.FormID);
                f.FormDetails  = "Course Registration: " + courseRegForm.Subject + " (" + courseRegForm.SubjectCode + ")";
                f.StudentPhone = form.StudentPhone;
                //crf.StudentPhone = courseRegForm.StudentPhone;
                crf.Subject         = courseRegForm.Subject;
                crf.SubjectCode     = courseRegForm.SubjectCode;
                f.SemesterName      = form.SemesterName;
                db.Entry(crf).State = EntityState.Modified;
                db.SaveChanges();
                if (DAL.UserInfo.Role.Equals("Student"))
                {
                    return(RedirectToAction("Index", "Student"));
                }
                else if (DAL.UserInfo.Role.Contains("Staff"))
                {
                    return(RedirectToAction("Index", "Staff"));
                }
                else
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            DateTime today = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("SE Asia Standard Time"));

            ViewBag.SemesterName = new SelectList(db.Semesters.Where(s => s.EndDate > today), "Name", "Name");
            ViewBag.FormID       = new SelectList(db.Forms, "ID", "Type", courseRegForm.FormID);
            return(View(courseRegForm));
        }
        public ActionResult CourseRegCreate([Bind(Include = "StudentPhone,SubjectCode,Subject,Status,Class,SemesterName")] CourseRegForm courseRegForm, Form form)
        {
            if (ModelState.IsValid)
            {
                //Form form = new Form();
                form.Type        = "Course Registration";
                form.Date        = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("SE Asia Standard Time"));
                form.CurrentDesk = "Academic-Staff";
                form.Flow        = "Academic-Staff,";
                form.FormDetails = "Course Registration: " + courseRegForm.Subject + " (" + courseRegForm.SubjectCode + ")";
                ArrayList UserDetails = DAL.Users.GetUser();
                form.StudentRollNo = Users.GetStudentRollNo(UserDetails[0].ToString(), UserDetails[1].ToString());
                form.StudentEmail  = UserDetails[2].ToString();
                form.StudentName   = UserDetails[0].ToString();
                form.Status        = "New";
                db.Forms.Add(form);
                db.SaveChanges();
                courseRegForm.FormID = form.ID;
                db.CourseRegForms.Add(courseRegForm);
                db.SaveChanges();
                return(RedirectToAction("Index", "Student"));
            }
            DateTime today = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("SE Asia Standard Time"));

            ViewBag.SemesterName = new SelectList(db.Semesters.Where(s => s.EndDate > today), "Name", "Name");
            ViewBag.FormID       = new SelectList(db.Forms, "ID", "Type", courseRegForm.FormID);
            return(View(courseRegForm));
        }
        // GET: CourseRegForms/Details/5
        public ActionResult CourseRegDetails(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CourseRegForm courseRegForm = db.CourseRegForms.Find(id);

            if (courseRegForm == null)
            {
                return(HttpNotFound());
            }
            return(View(courseRegForm));
        }
        // GET: CourseRegForms/Delete/5
        public ActionResult CourseRegDelete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CourseRegForm courseRegForm = db.CourseRegForms.Find(id);
            Form          form          = db.Forms.Find(id);

            if (!form.Status.Equals("New"))
            {
                return(RedirectToAction("Details", new { id = id }));
            }
            if (courseRegForm == null)
            {
                return(HttpNotFound());
            }
            return(View(courseRegForm));
        }
Beispiel #5
0
        public ActionResult CourseRegEndorsement(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CourseRegForm courseRegForm = db.CourseRegForms.Find(id);

            AllFormModel allFormModels = new AllFormModel()
            {
                Form = db.Forms.Find(id),
                SuspendSubjectForm = db.SuspendSubjectForms.Find(id)
            };

            if (courseRegForm == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Comment = new List <FormComment>(db.FormComments.Where(fc => fc.FormID == id));
            ViewBag.FormID  = new SelectList(db.Forms, "ID", "Type", courseRegForm.FormID);
            return(View(courseRegForm));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            CourseRegForm courseRegForm = db.CourseRegForms.Find(id);

            db.CourseRegForms.Remove(courseRegForm);
            Form form = db.Forms.Find(id);

            db.Forms.Remove(form);
            db.SaveChanges();
            if (DAL.UserInfo.Role.Equals("Student"))
            {
                return(RedirectToAction("Index", "Student"));
            }
            else if (DAL.UserInfo.Role.Contains("Staff"))
            {
                return(RedirectToAction("Index", "Staff"));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
        // GET: CourseRegForms/Edit/5
        public ActionResult CourseRegEdit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CourseRegForm courseRegForm = db.CourseRegForms.Find(id);
            Form          form          = db.Forms.Find(id);

            if (!form.Status.Equals("New"))
            {
                return(RedirectToAction("Details", new { id = id }));
            }
            if (courseRegForm == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FormID = new SelectList(db.Forms, "ID", "Type", courseRegForm.FormID);
            DateTime today = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("SE Asia Standard Time"));

            ViewBag.SemesterName = new SelectList(db.Semesters.Where(s => s.EndDate > today), "Name", "Name");
            return(View(courseRegForm));
        }
Beispiel #8
0
        public async Task <ActionResult> CourseRegEndorsement([Bind(Include = "FormID,TuitionFee")]
                                                              CourseRegForm courseRegForm, FormCollection collection)
        {
            string ForwardTo        = collection["ForwardTo"] + "";
            string FormStatus       = collection["FormStatus"] + "";
            string IsWeekBefore     = collection["IsWeekBefore"] + "";
            string NotAllSubject    = collection["NotAllSubject"] + "";
            string formComment      = collection["formComment"] + "";
            string TuitionFee       = collection["TuitionFee"] + "";
            string CoursesAvailable = collection["CoursesAvailable"] + "";

            CourseRegForm crf = db.CourseRegForms.Find(courseRegForm.FormID);
            Form          f   = db.Forms.Find(courseRegForm.FormID);
            FormComment   fC  = new FormComment();

            if (!formComment.Equals(""))
            {
                fC.FormID  = courseRegForm.FormID;
                fC.Comment = formComment;
                fC.RoleID  = Helper.Help.GetRoleId(DAL.UserInfo.Role);
                db.FormComments.Add(fC);
            }
            if (FormStatus.Equals(""))
            {
                f.Status = "Inprogress";
            }
            else
            {
                f.Status = FormStatus;
            }
            string getCurrentDesk = "";

            if (ForwardTo != "")
            {
                getCurrentDesk = Helper.Help.GetCurrentDesk(Int32.Parse(ForwardTo));
            }
            if (getCurrentDesk.Equals("Student"))
            {
                //send mail to notify student
                string notifyMessage = "<p>Please provide more information like: </p>"
                                       + "<p>====================================</p>" + fC.Comment;
                await SendNotification(notifyMessage, DAL.UserInfo.Email, f.StudentEmail);

                //Set status To new
                f.Status      = "New";
                f.CurrentDesk = "Student";
                f.Flow        = f.Flow + "Student,";
            }
            else if (getCurrentDesk.Length > 4)
            {
                f.CurrentDesk = getCurrentDesk;
                f.Flow        = f.Flow + f.CurrentDesk + ",";
            }
            if (IsWeekBefore != null)
            {
                if (IsWeekBefore.Equals("on"))
                {
                    crf.IsWeekBefore = true;
                }
                else
                {
                    crf.IsWeekBefore = false;
                }
            }

            if (TuitionFee != null)
            {
                if (TuitionFee.Equals("on"))
                {
                    crf.TuitionFee = true;
                }
                else
                {
                    crf.TuitionFee = false;
                }
            }
            crf.CoursesAvailable = CoursesAvailable;
            db.Entry(crf).State  = EntityState.Modified;
            db.SaveChanges();
            if (f.Status.Equals("Approved") || f.Status.Equals("Rejected"))
            {
                f.ApprovalDate = DateTime.Now.ToString();
                f.ApprovalBy   = DAL.UserInfo.Role;
                Helper.Notify notify = new Helper.Notify();

                string notifyMessage = "<p>Your form: " + f.Type + "</p> "
                                       + "<p>Student Name:     " + f.StudentName + "</p>"
                                       + "<p>Student RollNo:   " + f.StudentRollNo + "</p>"
                                       + "<p>Student Email:    " + f.StudentEmail + "</p>"
                                       + "<p>Student Phone:    " + f.StudentPhone + "</p>"
                                       + "<p>Semester:         " + f.SemesterName + "</p>"
                                       + "<p>Subject:   " + crf.Subject + " " + crf.SubjectCode + " </p>"
                                       + " has been <b>" + f.Status + "</b>";
                await SendNotification(notifyMessage, DAL.UserInfo.Email, f.StudentEmail);
            }
            return(RedirectToAction("Index", "Staff"));
        }