コード例 #1
0
        protected void btnSaveSubscriptions_Click(object sender, EventArgs e)
        {
            crud crud = new crud();

            List<child> subscribedChildren = (List<child>) Session["subscribedChildren"] ?? new List<child>();

            int courseID = Convert.ToInt32(Request.QueryString["courseID"]);
            course course = crud.selectCourse(courseID);

            subscription subscription = new subscription();
            subscription.course = course;
            subscription.paymentConfirmed = false;

            subscribedChildren.ForEach(child => child.id = child.id >= int.MaxValue - 10000 ? crud.insertChild(child) : child.id);

            foreach (child child in subscribedChildren) {
                subscription.child = child;
                if (new crud().getSubscriptionOnCourseAndChild(course.id, child.id).Count < 1) {
                    crud.insertSubscription(subscription);
                }
            };

            ((NinaSubscriptionsMaster) this.Master).setMessage(messageClasses.messageSuccess, settingsHelper.get("success_subscriptions_saved"));
        }