Example #1
0
        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");
        }
Example #2
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            // validate input
            if (this.ValidateInput() == false)
                return;

            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // fetch current schedule
            Schedule schedule = db.Schedules.SingleOrDefault(z => z.ID == new Guid(Request.QueryString["id"]));

            // set schedule properties
            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;

            // update schedule in database
            db.SubmitChanges();

            // close connection
            db.Dispose();

            // bind data to page
            this.BindData();
        }
Example #3
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            // validate input
            if (this.ValidateInput() == false)
                return;

            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // create new account
            Common.Account account = new Common.Account();

            // set account properties
            account.ID = Guid.NewGuid();
            account.EmailAddress = this.txtEmailAddress.Text;
            account.Password = Utilities.HashPassword(this.txtPassword.Text);
            account.Type = 1;
            account.CreatedDate = DateTime.UtcNow;

            // insert account to database
            db.Accounts.InsertOnSubmit(account);
            db.SubmitChanges();

            // close connection
            db.Dispose();

            // redirect to default page
            Response.Redirect("~/login.aspx?success=true");
        }
Example #4
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            // validate input
            if (this.ValidateInput() == false)
                return;

            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // fetch current account
            Common.Account account = db.Accounts.SingleOrDefault(z => z.ID == (Session["CurrentAccount"] as Common.Account).ID);

            // set schedule properties
            account.EmailAddress = this.txtEmailAddress.Text;
            if (this.txtPassword.Text.Length > 0)
            {
                account.Password = Utilities.HashPassword(this.txtPassword.Text);
            }

            // update schedule in database
            db.SubmitChanges();

            // close connection
            db.Dispose();

            // update schedule in session
            Session["CurrentAccount"] = account;

            // bind data to page
            this.BindData();
        }
Example #5
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // fetch current schedule
            Schedule schedule = db.Schedules.SingleOrDefault(z => z.ID == new Guid(Request.QueryString["id"]));

            // delete schedule from database
            db.Schedules.DeleteOnSubmit(schedule);
            db.SubmitChanges();

            // close connection
            db.Dispose();

            // redirect to default page
            Response.Redirect("~/default.aspx");
        }
Example #6
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // fetch current account
            Common.Account account = db.Accounts.SingleOrDefault(z => z.ID == (Session["CurrentAccount"] as Common.Account).ID);

            // delete account from database
            db.Accounts.DeleteOnSubmit(account);
            db.SubmitChanges();

            // close connection
            db.Dispose();

            // redirect to logout page
            Response.Redirect("~/logout.aspx");
        }