예제 #1
0
        public JsonResult add_Submit(string content)
        {
            using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content)))
            {
                // Deserialization from JSON
                DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(Course_Insert_Helper));
                Course_Insert_Helper       course       = (Course_Insert_Helper)deserializer.ReadObject(ms);
                long id = Course_crud.addCourse(course);

                Course_crud.addCourseTag(id, course.name);
                Course_crud.addCourseTag(id, course.name_ar);
                Course_crud.addCourseTag(id, course.description);
                Course_crud.addCourseTag(id, course.description_ar);
            }
            return(Json("chamara", JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public static long addCourse(Course_Insert_Helper helper)
        {
            Course course = new Course
            {
                instructor_id  = 0,
                branch_id      = helper.branch_id,
                course_type_id = helper.CourseType,

                name           = helper.name,
                name_ar        = helper.name_ar,
                description    = helper.description,
                description_ar = helper.description_ar,

                start_date = Convert.ToDateTime(helper.start_date),
                end_date   = Convert.ToDateTime(helper.end_date),
                capacity   = helper.capacity,

                capacity_is_visible = is_visible_enum.visible,

                old_price = helper.old_price,
                new_price = helper.new_price,

                expiration_register_date = Convert.ToDateTime(helper.expiration_register_date),
                course_duration_in_hours = helper.course_duration_in_hours,
                no_of_days_per_week      = helper.no_of_days_per_week,
                no_of_hours_per_day      = helper.no_of_hours_per_day,

                center_or_instructor = center_or_instructor_enum.center,
                is_visible           = is_visible_enum.visible
            };
            long course_id = addCourse(course);
            int  i         = 0;

            foreach (int item in helper.Days)
            {
                CourseDays day = new CourseDays();
                day.course_id = course_id;
                day.day       = (days_of_week_enum)item;
                day.to_time   = Convert.ToDateTime(helper.Tos[i]);
                day.from_time = Convert.ToDateTime(helper.froms[i]);
                addCourseDay(day);
                i++;
            }


            return(course_id);
        }