public Subrace Update(Subrace subrace) { _context.Attach(subrace).State = EntityState.Modified; _context.SaveChanges(); return(subrace); }
private static Dictionary <string, Subrace> GetSubraces(AngleSharp.Dom.IElement mainDiv) { var subraces = new Dictionary <string, Subrace>(); var headers = mainDiv.QuerySelectorAll("H3"); foreach (var header in headers) { string subraceName = header.TextContent.Trim(); if (subraceName == "Arbandi Elf Clans") { break; } string description = ReadSubraceDescription(header); List <Ability> abilities = ReadAbilities(header); var subrace = new Subrace { name = subraceName, description = description, abilities = abilities }; subraces.Add(subrace.name, subrace); } return(subraces); }
public Subrace Add(Subrace subrace) { _context.Subraces.Add(subrace); _context.SaveChanges(); return(subrace); }
public string getInvalidElements() { string output = ""; if (subraceListBox.SelectedItems.Count == 0) { output += raceBox.Text; } if (subraceListBox.SelectedItems.Count > 0) { Subrace currentSubrace = subraceListBox.SelectedItem as Subrace; if (currentSubrace != null) { if (currentSubrace.HasProficiencyChoice && (extraChoiceBox.SelectedItems.Count == 0)) { if (!string.IsNullOrEmpty(output)) { output += ", "; } output += "bonus race proficiency"; } } } return(output); }
private void subraceListBox_SelectedIndexChanged(object sender, EventArgs e) { Subrace currentSubrace = subraceListBox.SelectedItem as Subrace; if (currentSubrace != null) { descriptionLabel.Text = currentSubrace.Description; if (currentSubrace.HasProficiencyChoice) { descriptionLabel.MaximumSize = new Size(520, descriptionLabel.MaximumSize.Height); extraChoiceLayout.Visible = true; fillExtraChoiceListBox(currentSubrace.Name); } else { descriptionLabel.MaximumSize = new Size(650, descriptionLabel.MaximumSize.Height); extraChoiceLayout.Visible = false; } } saveContent(); OnSubraceChanged(null); }
public void UpdateSubrace(SubraceUpdateModel subraceToUpdate, int subraceId) { Subrace entity = _ctx.Subraces.Single(e => e.SubraceId == subraceId); if (entity != null) { if (subraceToUpdate.UpdatedSubraceName != null) { entity.SubraceName = subraceToUpdate.UpdatedSubraceName; } if (subraceToUpdate.UpdatedSubraceDescription != null) { entity.SubraceDescription = subraceToUpdate.UpdatedSubraceDescription; } if (subraceToUpdate.UpdatedAbilityScoreIncrease != null) { entity.AbilityScoreIncrease = subraceToUpdate.UpdatedAbilityScoreIncrease; } if (subraceToUpdate.UpdatedSource != null) { entity.Source = subraceToUpdate.UpdatedSource; } if (subraceToUpdate.UpdatedOrigin != null) { entity.Origin = subraceToUpdate.UpdatedOrigin; } if (subraceToUpdate.UpdatedRaceId != null) { entity.RaceId = (int)subraceToUpdate.UpdatedRaceId; } _ctx.SaveChanges(); } }
private void loadPreviousSelection() { Subrace savedSubrace = wm.Choices.RaceChoice.getSelectedSubrace(); if (raceListBox.Items.Contains(wm.Choices.RaceChoice)) { raceListBox.SetSelected(raceListBox.Items.IndexOf(wm.Choices.RaceChoice), true); } if (subraceListBox.Items.Contains(savedSubrace)) { subraceListBox.SetSelected(subraceListBox.Items.IndexOf(savedSubrace), true); } }
private void btnDelete_Click(object sender, EventArgs e) { if (dGrid.SelectedRows.Count > 0) { if (MessageBox.Show("Are you sure you wish to delete?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int raceId = Convert.ToInt32(dGrid.SelectedRows[0].Cells[0].Value); Subrace obj = conn.Subraces.SingleOrDefault(E => E.Id == raceId); conn.Subraces.DeleteOnSubmit(obj); conn.SubmitChanges(); } } LoadData(fontSize); }
public void CreateSubrace(SubraceCreateModel subraceToCreate) { Subrace entity = new Subrace() { SubraceName = subraceToCreate.SubraceName, SubraceDescription = subraceToCreate.SubraceDescription, AbilityScoreIncrease = subraceToCreate.AbilityScoreIncrease, Source = subraceToCreate.SubraceSource, Origin = subraceToCreate.SubraceOrigin }; _ctx.Subraces.Add(entity); _ctx.SaveChanges(); }
public bool isValid() { if (subraceListBox.SelectedItems.Count > 0) { Subrace currentSubrace = subraceListBox.SelectedItem as Subrace; if (currentSubrace != null) { if (currentSubrace.HasProficiencyChoice) { return((subraceListBox.SelectedItems.Count > 0) && (extraChoiceBox.SelectedItems.Count > 0)); } } } return(subraceListBox.SelectedItems.Count > 0); }
public SubraceDetailModel GetSubraceDetailById(int subraceId) { Subrace subrace = _ctx.Subraces.Single(e => e.SubraceId == subraceId); SubraceDetailModel entity = new SubraceDetailModel() { SubraceId = subrace.SubraceId, SubraceName = subrace.SubraceName, SubraceDescription = subrace.SubraceDescription, AbilityScoreIncrease = subrace.AbilityScoreIncrease, Source = subrace.Source, Origin = subrace.Origin, ParentRaceName = subrace.ParentRace.RaceName }; return(entity); }
public void saveContent() { Race currentRace = raceListBox.SelectedItem as Race; Subrace currentSubrace = subraceListBox.SelectedItem as Subrace; if ((currentRace != null) && (currentSubrace != null)) { if (currentSubrace.HasProficiencyChoice) { currentSubrace.Proficiency = extraChoiceBox.SelectedItem.ToString(); } else { currentSubrace.Proficiency = ""; } currentSubrace.HasExtraSpells = wm.DBManager.ExtraRaceChoiceData.hasExtraRaceCantripChoice(currentSubrace.Name); currentRace.setSelectedSubrace(currentSubrace); wm.Choices.RaceChoice = currentRace; } }
private void fillExtraChoiceListBox(string inputSubrace) { Subrace currentSubrace = subraceListBox.SelectedItem as Subrace; if (currentSubrace != null) { extraChoiceSource = wm.DBManager.RaceData.getExtraRaceProficiencies(currentSubrace.Name); extraChoiceBox.BeginUpdate(); extraChoiceBox.DataSource = null; extraChoiceBox.DataSource = extraChoiceSource; extraChoiceBox.EndUpdate(); if (extraChoiceBox.Items.Contains(wm.Choices.RaceChoice.getSelectedSubrace().Proficiency)) { extraChoiceBox.SetSelected(extraChoiceBox.Items.IndexOf(wm.Choices.RaceChoice.getSelectedSubrace().Proficiency), true); } //else //{ // extraChoiceBox.SetSelected(0, true); //} } }
private void btnAccept_Click(object sender, EventArgs e) { if (txtName.Text == "" || cbBoxRace.Text == "") { MessageBox.Show("Missing required information"); } else { if (beingEdited == false) { var query = from race in db.Races where race.Name == cbBoxRace.Text select race.Id; //Sets the race foreign key foreach (int ID in query) { raceID = ID; } Subrace sub = new Subrace { Name = txtName.Text, RaceId = raceID, Speed = Convert.ToInt32(txtSpeed.Text), Strength = Convert.ToInt32(txtStr.Text), Dexterity = Convert.ToInt32(txtDex.Text), Constitution = Convert.ToInt32(txtCon.Text), Intelligence = Convert.ToInt32(txtInt.Text), Wisdom = Convert.ToInt32(txtWis.Text), Charisma = Convert.ToInt32(txtCha.Text) }; db.Subraces.InsertOnSubmit(sub); db.SubmitChanges(); this.Close(); } else { //updates race ID if necessary var raceQuery = from race in db.Races where race.Name == cbBoxRace.Text select race.Id; foreach (int id in raceQuery) { raceID = id; } var query = from subrace in db.Subraces where subrace.Id == id select subrace; foreach (Subrace sub in query) { sub.RaceId = raceID; sub.Name = txtName.Text; sub.Speed = (int)txtSpeed.Value; sub.Strength = (int)txtStr.Value; sub.Dexterity = (int)txtDex.Value; sub.Constitution = (int)txtCon.Value; sub.Intelligence = (int)txtInt.Value; sub.Wisdom = (int)txtWis.Value; sub.Charisma = (int)txtCha.Value; } try { db.SubmitChanges(); this.Close(); } catch (Exception exc) { MessageBox.Show($"Error: {exc}"); } } DialogResult = DialogResult.OK; } }
public void DeleteSubrace(int subraceId) { Subrace entity = _ctx.Subraces.Single(e => e.SubraceId == subraceId); _ctx.Subraces.Remove(entity); }
public void updateRaceAlignmentDescription(Subrace inputSubrace) { raceAlignmentLabel.Text = inputSubrace.AlignmentDescription; }