Exemple #1
0
        public ActionResult CourseSurveySchedule(FormCollection collection)
        {
            int    DaysToOpen = 0, DaysOpen = 0;
            int?   CourseId = null, QuestionGroupId = null;
            char?  Session = null;
            string StatusIdsString;
            bool   Active = false;

            if (collection["Course"] != null)
            {
                CourseId = Convert.ToInt32(collection["Course"].ToString());
            }
            else
            {
                prepareCourseSurveySchedualViewData("Course could not be empty");
                return(View());
            }

            if (collection["Session"] != null)
            {
                Session = Convert.ToChar(collection["Session"]);
            }
            else
            {
                prepareCourseSurveySchedualViewData("Session could not be empty");
                return(View());
            }

            int.TryParse(collection["DaysToOpen"], out DaysToOpen);
            int.TryParse(collection["DaysOpen"], out DaysOpen);
            StatusIdsString = collection["inputSelectStudentStatuses"] as string;
            if (collection["Question Group"] != null)
            {
                QuestionGroupId = Convert.ToInt32(collection["Question Group"]);
            }

            if (collection["chkBoxActive"] != null && collection["chkBoxActive"].ToString().Contains("true"))
            {
                Active = true;
            }

            SurveyCourseSchedule scs = new SurveyCourseSchedule()
            {
                CourseInfo = new Course()
                {
                    CourseNo = CourseId
                },
                SessionInfo = new Session()
                {
                    SessionInfo = Session + ""
                },
                DaysToOpen            = DaysToOpen,
                DaysOpen              = DaysOpen,
                StudentStatusesString = StatusIdsString,
                QuestionGroupInfo     = new QuestionGroup()
                {
                    QuestionGroupID = QuestionGroupId.Value
                },
                Active = Active
            };

            try
            {
                service.CreateCourseSurveySchedule(scs);
                prepareCourseSurveySchedualViewData("Saved Successfully");
                return(View());
            }
            catch (Exception error)
            {
                prepareCourseSurveySchedualViewData(error.Message);
                return(View());
            }
        }