Пример #1
0
        // Deletes this character from the database and the filesystem
        protected void DeleteCharacterButton_Click(object sender, EventArgs e)
        {
            //TODO: add confirm delete dialog box (should use javascript)

            //delete character file in filesystem
            File.Delete(filePath);

            CharacterDataSource.DeleteCommand = "DELETE FROM Characters WHERE Id = " + characterData.Field <Int32>("Id").ToString();
            CharacterDataSource.Delete();

            Response.Redirect("~/CharacterList.aspx");
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)             // if the user is not logged in
            {
                Response.Redirect("~/Account/Login.aspx");
                return;
            }

            try
            {
                SheetDataView = (DataView)CharacterDataSource.Select(DataSourceSelectArguments.Empty);

                if (SheetDataView.Table.Rows.Count == 0)
                {
                    DisplayAlert("No Character with that ID exists, or that character belongs to another user");
                    Response.Redirect("~/CharacterList.aspx");
                }
                else
                {
                    characterData = SheetDataView.Table.Rows[0];                             //set the field characterData

                    if ((User.Identity.GetUserId() != characterData.Field <string>("User"))) // This should never happen, but in case something wierd happens, it's here as a safety net
                    {
                        DisplayAlert("That character belongs to a different user");
                        Response.Redirect("~/CharacterList.aspx");
                    }
                    else
                    {
                        //Set the text boxes on the page to have the correct data
                        NameTextBox.Text        = characterData.Field <string>("Name");
                        ActiveCheckBox.Checked  = (characterData.Field <bool>("Active"));                           //FIXME: this probably won't work, maybe?
                        DateCreatedTextBox.Text = characterData.Field <DateTime>("DateCreated").ToLongDateString(); //FIXME: this might not work, hopefully will

                        //read the text from the saved character sheet file
                        filePath = Server.MapPath("~/UserSheets/" + characterData.Field <string>("User") + "/" + characterData.Field <Int32>("Id").ToString() + ".txt");
                        if (File.Exists(filePath))
                        {
                            SheetTextBox.Text = File.ReadAllText(filePath);
                        }
                    }
                }
            }
            catch (Exception x)
            {
                DisplayAlert(x.Message);                        //This should be handled better
            }
        }
Пример #3
0
 public CharacterRepository(CharacterDataSource remoteRepo)
 {
 }