public string saveChangesToCourse(string courseID, string description, string courseTypeID, string startDate, string endDate, string locationID, string maxSubscriptions, string price, string startHour, string endHour, string name) { const string success = "success"; const string failed = "failed"; // validate fields before continuing if (string.IsNullOrWhiteSpace(courseID) || string.IsNullOrWhiteSpace(description) || string.IsNullOrWhiteSpace(courseTypeID) || string.IsNullOrWhiteSpace(startDate) || string.IsNullOrWhiteSpace(endDate) || string.IsNullOrWhiteSpace(locationID) || string.IsNullOrWhiteSpace(maxSubscriptions) || string.IsNullOrWhiteSpace(price) || string.IsNullOrWhiteSpace(startHour) || string.IsNullOrWhiteSpace(endHour) || string.IsNullOrWhiteSpace(name)) { return "Gelieve alle velden in te vullen of na te kijken"; } customValidator validator = new customValidator(); if (!validator.validDate(startDate) || !validator.validDate(endDate)) return "Gelieve geldige datums in te vullen (dd/mm/yyyy)"; if (!validator.hour(startHour) || !validator.hour(endHour)) return "Gelieve geldige uren in te vullen (hh:mm)"; // if all is validated, continue... crud crud = new crud(); course course = crud.selectCourse(Convert.ToInt32(courseID)); course.name = name; course.description = description; course.courseType = crud.selectCourseType(Convert.ToInt32(courseTypeID)); course.startDate = Convert.ToDateTime(startDate); course.endDateInclusive = Convert.ToDateTime(endDate); course.location = crud.selectLocation(Convert.ToInt32(locationID)); course.maxSubscriptions = Convert.ToInt32(maxSubscriptions); course.price = Convert.ToInt32(price); course.startHour = startHour; course.endHour = endHour; if (crud.updateCourse(course) > 0) { return success; }; return failed; }
// initializers protected void Page_Load(object sender, EventArgs e) { NinaSubscriptionsMaster master = this.Master as NinaSubscriptionsMaster; master.setHeaderTitle(settingsHelper.get("title_subscribe_to_course")); userProfile user = master.getLoggedInUserProfile(); if (user == null) { Response.Redirect(settingsHelper.get("default_redirect_page")); }; int courseID = Convert.ToInt32(Request.QueryString["courseID"]); crud crud = new crud(); course course = crud.selectCourse(courseID); fillCourseData(course); if (!IsPostBack) { Session.Remove("subscribedChildren"); refreshLists(courseID); }; }
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")); }