public async Task <IActionResult> PutSelectedSkill([FromRoute] long id, [FromBody] SelectedSkill selectedSkill) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != selectedSkill.SelectedSkillId) { return(BadRequest()); } _context.Entry(selectedSkill).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SelectedSkillExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostSelectedSkill([FromBody] SelectedSkill selectedSkill) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.SelectedSkills.Add(selectedSkill); await _context.SaveChangesAsync(); return(CreatedAtAction("GetSelectedSkill", new { id = selectedSkill.SelectedSkillId }, selectedSkill)); }
public void DecideMove(List <Player> players, List <Enemy> enemies) { if (!IsConscious) { return; } SelectedTargets.Clear(); SelectedSkill = Skills.Count > 0 ? Skills[RandInt(0, Skills.Count - 1)] : null; SelectedItem = null; SelectedWeapon = Weapons.Count > 0 && SelectedSkill != null && SelectedSkill.IsOffense() ? Weapons[RandInt(0, Weapons.Count - 1)] : null; SelectedTargets.Add(players[RandInt(0, players.Count - 1)]); }
private void SaveSkill() { //if (String.IsNullOrEmpty(SelectedSkill.Skill_ID.ToString())) //{ // MessageBox.Show("Please Enter First Name", "First Name Required", MessageBoxButton.OK, MessageBoxImage.Error); // return; //} if (String.IsNullOrEmpty(SelectedSkill.SkillType) ) { MessageBox.Show("Please Enter skill Type", "Skill Type Required", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (SelectedSkill.Skill_ID == 0) { try { SelectedSkill.Insert(); MessageBox.Show("Thank you! The new Skill's details have been added to the Database.", "Skill", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception) { MessageBox.Show("Something Went Wrong, But we Dont know what! Skill was not added to the database"); } } else { try { SelectedSkill.Update(); MessageBox.Show("The skill's details have been updated in the Database.", "Update Skill?", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show("An Error Occured, The Skill Details were not updated. Please Contact your System Administrator.", "Update Skill?" + ex.Message); } } IsEnabledAdd = true; IsEnabledSave = true; IsEnabledDelete = true; }
private void DeleteSkill() { try { if (MessageBox.Show("Are you sure you want to PERMANENTLY delete the skill's details?", "Delete Skill?", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { SelectedSkill.Delete(); SkillCollection.Remove(SelectedSkill); MessageBox.Show("Thank you! The Skill's details have been deleted!", "Delete Skill?", MessageBoxButton.OK, MessageBoxImage.Information); } else { return; } } catch (Exception ex) { MessageBox.Show("An Error Occured, The Skill Details have not been deleted. Please Contact your System Administrator.", "Delete Skill?" + ex.Message); } }