Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    if (MessageID >= 0)
                    {
                        DB.Message message = DB.Message.Get(MessageID);

                        // at 1st check the message belongs to CurrentUserID
                        if (message.UserID != CurrentUser.ID)
                        {
                            throw new Exception();
                        }

                        editTitle.Text                = message.Title;
                        editMessage.Text              = message.Text;
                        ddlSendIn.SelectedValue       = message.SendIn_Hours.ToString();
                        ddlNotifyBefore.SelectedValue = message.NotifyBefore_Hours.ToString();

                        UpdateRecipientList(message.ID);
                    }
                }
                catch
                {
                    Response.Redirect(".");
                }
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // TODO check if message belongs to the current user


            int messageID = int.Parse(Request.QueryString["ID"]);

            // recipients and destinations will be deleted via db diagram voila :)
            DB.Message message = DB.Message.Get(messageID);
            if (message != null)
            {
                message.Delete();
            }

            Response.Redirect("Home.aspx");
        }
Esempio n. 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            DB.Message message = null;

            if (MessageID >= 0)
            {
                message = DB.Message.Get(MessageID);
            }
            else
            {
                message = new DB.Message()
                {
                    ID     = -1,
                    Status = DB.MessageStatus.ACTIVE,
                    UserID = CurrentUser.ID,
                };
            }

            message.Title              = editTitle.Text;
            message.Text               = editMessage.Text;
            message.SendIn_Hours       = int.Parse(ddlSendIn.SelectedValue);
            message.NotifyBefore_Hours = int.Parse(ddlNotifyBefore.SelectedValue);

            // reset timer // TODO? RESET ALL ?????
            message.SendTime = DateTime.Now.AddHours(message.SendIn_Hours);

            message = message.Save();

            if (MessageID >= 0)
            {
                Response.Redirect("Home.aspx");
            }
            else
            {
                Response.Redirect("EditMessage.aspx?ID=" + message.ID.ToString());  // let user to not leave the new message and to add recipients
            }
        }