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_beheer_cursussen")); userProfile user = master.getLoggedInUserProfile(); if (user == null || user.isAdmin == false) { Response.Redirect("~/Pages/Public/bekijkAanbod.aspx"); }; crud crud = new crud(); locations = crud.getAllLocations(); courseTypes = crud.getAllCourseTypes(); if (IsPostBack) { try { selectedCourseType = crud.selectCourseType(Convert.ToInt32(ddNewCourseType.SelectedValue)); selectedLocation = crud.selectLocation(Convert.ToInt32(ddNewLocation.SelectedValue)); } catch { // objecten blijven null, hierop wordt later gecontroleerd } } else { fillCoursesList(crud); } }