protected void btnCreate_Click(object sender, EventArgs e) { // validate input if (this.ValidateInput() == false) return; // connect to database DatabaseDataContext db = new DatabaseDataContext(); // create new schedule Schedule schedule = new Schedule(); // set schedule properties schedule.ID = Guid.NewGuid(); schedule.AccountID = (Session["CurrentAccount"] as Common.Account).ID; schedule.Name = this.txtName.Text; schedule.Occurrence = CrontabSchedule.Parse(this.txtOccurrence.Text).ToString(); schedule.NextOccurrence = CrontabSchedule.Parse(schedule.Occurrence).GetNextOccurrence(DateTime.UtcNow); schedule.Endpoint = this.txtEndpoint.Text; schedule.IsEnabled = true; schedule.CreatedDate = DateTime.UtcNow; // insert schedule to database db.Schedules.InsertOnSubmit(schedule); db.SubmitChanges(); // close connection db.Dispose(); // redirect to default page Response.Redirect("~/default.aspx"); }
partial void DeleteSchedule(Schedule instance);
partial void UpdateSchedule(Schedule instance);
partial void InsertSchedule(Schedule instance);
private void detach_Schedules(Schedule entity) { this.SendPropertyChanging(); entity.Account = null; }
private void attach_Schedules(Schedule entity) { this.SendPropertyChanging(); entity.Account = this; }