Beispiel #1
0
        protected void lnkUpdateEvent_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            try
            {
                using (TeamSchedulesController tsc = new TeamSchedulesController())
                {
                    // get clean copy
                    TeamSchedule teamSchedule = tsc.Get(TeamScheduleID.Value);
                    teamSchedule.ModifyDate = DateTime.Now.ToUniversalTime();
                    teamSchedule.ModifyUserID = CurrentUser.UserID;
                    teamSchedule.EventName = txtEventName.Text;
                    teamSchedule.TeamID = ptpPicker.SelectedTeamID.Value;
                    teamSchedule.StartDate = DateTime.Parse(txtStartDate.Text).ToUniversalTime();
                    teamSchedule.EndDate = DateTime.Parse(txtEndDate.Text).ToUniversalTime();
                    teamSchedule.RSVPBy = chkEnableRSVP.Checked && !string.IsNullOrWhiteSpace(txtRSVPBy.Text) ? DateTime.Parse(txtRSVPBy.Text).ToUniversalTime() : (DateTime?)null;

                    tsc.Update(teamSchedule);

                    Response.Redirect(ResolveUrl("~/Modules/Scheduler/"));
                }
            }
            catch (Exception ex)
            {
                AlertBox_Manage.SetStatus("An error occurred while trying to create new event.", UI.AlertBoxType.Error);
            }
        }
        protected void lnkDelete_Click(object sender, EventArgs e)
        {
            if(!TeamScheduleID.HasValue){
                return;
            }

            if (TeamScheduleDeleted == null)
            {
                throw new Exception("No event supplied when team schedule is deleted. Cannot delete");
            }
            else
            {
                try
                {
                    using (TeamSchedulesController tsc = new TeamSchedulesController())
                    {
                        TeamSchedule teamSchedule = tsc.Get(TeamScheduleID.Value);
                        teamSchedule.IsActive = false;
                        teamSchedule.DeleteDate = DateTime.Now.ToUniversalTime();
                        teamSchedule.DeleteUserID = CurrentUser.UserID;
                        tsc.Update(teamSchedule);

                        OnTeamScheduleDeleted(new TeamScheduleEvent()
                        {
                            Message = "Successfully deleted the event.",
                            MessageType = UI.AlertBoxType.Success
                        });
                    }
                }
                catch (Exception ex)
                {
                    OnTeamScheduleDeleted(new TeamScheduleEvent()
                    {
                        Message = "An error occurred while attempting to delete the event.",
                        MessageType = UI.AlertBoxType.Error
                    });
                }
            }
        }