public IHttpActionResult PutRaceModel(Guid id, RaceModel raceModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != raceModel.Id) { return(BadRequest()); } db.Entry(raceModel).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RaceModelExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public CharacterPastLifeClass() { NumHeroic = ClassModel.GetNumClasses(); NumIconic = RaceModel.GetNumIconic(); PastLifeHerioc = new int[NumHeroic]; PastLifeIconic = new int[NumIconic]; //TODO: Epic Lives when destiny is done //NumEpic = HeroicNames = ClassModel.GetNames(); IconicNames = RaceModel.GetIconicNames(); //TODO: Epic Lives when destiny is done //EpicNames = for (int i = 0; i < NumHeroic; ++i) { PastLifeHerioc[i] = 0; } for (int i = 0; i < NumIconic; ++i) { PastLifeIconic[i] = 0; } //TODO:Epic Lives when destiny is done // for(int i = 0; i< NumEpic; ++i) // PastLifeEpic[i]=0; }
/// <summary> /// Creats an instance of <see cref="RaceListItemViewModel"/> /// </summary> public RaceListItemViewModel(RaceModel raceModel, StringService stringService) { _raceModel = raceModel; _stringService = stringService; Initialize(); }
public IHttpActionResult PostRaceModel(RaceModel raceModel) { raceModel.Id = Guid.NewGuid(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Races.Add(raceModel); try { db.SaveChanges(); } catch (DbUpdateException) { if (RaceModelExists(raceModel.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = raceModel.Id }, raceModel)); }
public static RaceModel ToModel(this Race bo, bool withJoin = false) { if (bo == null) { return(null); } RaceModel raceModel = new RaceModel(); raceModel.Id = bo.Id; raceModel.Title = bo.Title; raceModel.Description = bo.Description; raceModel.DateStart = bo.DateStart; raceModel.DateEnd = bo.DateEnd; raceModel.Town = bo.Town; raceModel.Distance = (int)bo.Distance; raceModel.Points = bo.Points.ToModels(); raceModel.Organisers = withJoin && bo.Organisers != null?bo.Organisers.Select(x => x.ToModel()).ToList() : null; raceModel.Competitors = withJoin && bo.Competitors != null?bo.Competitors.Select(x => x.ToModel()).ToList() : null; return(raceModel); }
public static Race ToBo(this RaceModel model) { if (model == null) { return(null); } Race newRace = new Race(); newRace.Id = model.Id; newRace.Title = model.Title; newRace.Description = model.Description; newRace.DateStart = model.DateStart; newRace.DateEnd = model.DateEnd; newRace.Town = model.Town; if (model.Points != null) { newRace.Distance = model.Distance; } if (model.Points != null) { newRace.Points = model.Points.Select(x => x.ToBo()).ToList(); } return(newRace); }
private void ImportRaces() { foreach (RaceModel raceModel in _races) { if (_addAllEntries) { _compendium.AddRace(raceModel); } else if (_skipDuplicateEntries) { if (!_compendium.Races.Any(x => x.Name.Equals(raceModel.Name, StringComparison.CurrentCultureIgnoreCase))) { _compendium.AddRace(raceModel); } } else if (_replaceExistingEntries) { RaceModel existing = _compendium.Races.FirstOrDefault(x => x.Name.Equals(raceModel.Name, StringComparison.CurrentCultureIgnoreCase)); if (existing == null) { _compendium.AddRace(raceModel); } else { raceModel.Id = existing.Id; _compendium.UpdateRace(raceModel); } } } }
public ActionResult CreatePDF(int id) { RaceModel result = MgtRace.GetInstance().GetRaceWithPoints(id).ToModel(false, true); Document doc = new Document(PageSize.LETTER, 50, 50, 50, 50); string html = RenderRazorViewToString("~/Views/Race/CreatePDF.cshtml", result); TextReader reader = new StringReader(html); using (MemoryStream output = new MemoryStream()) { PdfWriter wri = PdfWriter.GetInstance(doc, output); // step 3: we create a worker parse the document HTMLWorker worker = new HTMLWorker(doc); doc.Open(); worker.StartDocument(); // step 5: parse the html into the document worker.Parse(reader); // step 6: close the document and the worker worker.EndDocument(); worker.Close(); doc.Close(); return(File(output.ToArray(), "application/pdf", result.Title + ".pdf")); } }
public bool StartRace(int raceId, out string status) { RaceModel race = _dakarDbContext.Races.FirstOrDefault(x => x.Id == raceId); if (race != null) { if (!_dakarDbContext.Races.Any(x => x.Status == RaceStatus.Running)) { if (GetVehiclesFromRace(raceId).Count > 0) { if (race.Status == RaceStatus.Pending) { race.Status = RaceStatus.Running; status = "Success."; return(true); } status = "Race is finished!"; return(false); } status = "No vehicles in race!"; return(false); } status = "One race is already started!"; return(false); } status = $"No race with identifier {raceId} found!"; return(false); }
/// <summary> /// Creates an instance of <see cref="RaceViewModel"/> /// </summary> public RaceViewModel(RaceModel raceModel) { _raceModel = raceModel; _size = _raceModel.Size != CreatureSize.None ? _stringService.GetString(_raceModel.Size) : "Unknown"; _speed = raceModel.WalkSpeed.ToString() + " ft."; if (_raceModel.FlySpeed > 0) { _speed += ", Fly" + _raceModel.FlySpeed.ToString() + " ft."; } if (_raceModel.Abilities.Count > 0) { List <string> abilities = new List <string>(); foreach (KeyValuePair <Ability, int> pair in _raceModel.Abilities) { abilities.Add(_stringService.GetString(pair.Key) + " " + _statService.AddPlusOrMinus(pair.Value)); } _abilities = String.Join(", ", abilities); } else { _abilities = "None"; } foreach (TraitModel trait in _raceModel.Traits) { _traits.Add(new TraitViewModel(trait)); } }
public ActionResult AddPoint(RaceModel race) { try { RaceModel newRace = MgtRace.GetInstance().GetRace(race.Id).ToModel(); newRace.Points = new List <PointModel>(); newRace.Distance = race.Distance; var check = Request.Form["checkbox"]; if (check == null) { race.point.isPoi = false; race.point.Category = null; } else { race.point.isPoi = true; } newRace.Points.Add(race.point); var result = MgtRace.GetInstance().UpdateRace(newRace.ToBo()); RaceModel reloadRace = MgtRace.GetInstance().GetRace(race.Id).ToModel(); if (result) { return(Json(reloadRace)); } else { return(RedirectToAction("Index")); } } catch (Exception e) { return(View()); } }
/// <summary> /// True if the search input applies to the model /// </summary> public bool SearchInputApplies(RaceSearchInput searchInput, RaceModel raceModel) { return(HasSearchText(raceModel, searchInput.SearchText) && IsSize(raceModel, searchInput.Size.Key) && HasAbility(raceModel, searchInput.Ability.Key) && HasLanguage(raceModel, searchInput.Language.Key)); }
public GameObject[] ConstructCompetitors(RaceModel model, GameObject competitorPrefab) { int c; if (null != competitors) { for (c = 0; c < competitors.Length; c++) { Destroy(competitors[c]); } } competitors = new GameObject[SpeedModel.competitorCount]; for (c = 0; c < SpeedModel.competitorCount; c++) { Vector3 position = new Vector3(model.lanes[c], 0.25f, SpeedModel.competitors[c].z); competitors[c] = (GameObject)Instantiate( competitorPrefab, position, Quaternion.identity); competitors[c].SetActive(true); if (isVerbose) { Debug.Log("RaceController.Construct: " + c + " position " + competitors[c].transform.position); } } return(competitors); }
public IActionResult Delete(int id) { var model = new RaceDeleteViewModel(); model.Race = RaceModel.GenerateRaceModelFromDTO(work.RaceRepository.GetDTO(id)); return(View(model)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Title,Local,EventDate,Type")] RaceModel raceModel) { if (id != raceModel.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(raceModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RaceModelExists(raceModel.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(raceModel)); }
private string BuildRequirementText(Guid requirementId, string requirementComparison, double requirementValue) { string text; string tableName; RequirementModel reqModel; text = ""; //text = RequirementModel.GetNameFromId(requirementId) + " " + requirementComparison + " " + requirementValue.ToString(); reqModel = new RequirementModel(); reqModel.Initialize(requirementId); tableName = TableNamesModel.GetTableNameFromId(reqModel.TableNamesId); if (tableName == "Ability") { text = AbilityModel.GetNameFromId(reqModel.ApplytoId) + " " + requirementComparison + " " + requirementValue.ToString(); } else if (tableName == "Alignments") { text = "Alignment: " + requirementComparison + " " + AlignmentModel.GetNameFromID(reqModel.ApplytoId); } else if (tableName == "Attribute") { text = AttributeModel.GetNameFromId(reqModel.ApplytoId) + " " + requirementComparison + " " + requirementValue.ToString(); } else if (tableName == "Character") { text = "Character " + requirementComparison + " Level " + requirementValue.ToString(); } else if (tableName == "Class") { text = ClassModel.GetNameFromId(reqModel.ApplytoId) + " " + requirementComparison + " Level " + requirementValue.ToString(); } else if (tableName == "Enhancement") { text = "Enhnacement: " + EnhancementModel.GetNameFromId(reqModel.ApplytoId) + " " + requirementComparison + " Rank " + requirementValue.ToString(); } else if (tableName == "EnhancementSlot") { text = "Enhancement Slot: " + BuildSlotName(reqModel.ApplytoId) + " " + requirementComparison + " Rank " + requirementValue.ToString(); } else if (tableName == "Feat") { text = "Feat: " + FeatModel.GetNameFromId(reqModel.ApplytoId); } else if (tableName == "Race") { text = RaceModel.GetNameFromId(reqModel.ApplytoId) + " " + requirementComparison + " Level " + requirementValue.ToString(); } else if (tableName == "Skill") { text = SkillModel.GetNameFromId(reqModel.ApplytoId) + " " + requirementComparison + " " + requirementValue.ToString(); } else { //we should not reach here Debug.WriteLine("Error: No category exists for this requirement. RequirementPanel2: BuildRequirementText()"); } return(text); }
/// <summary> /// Adds a race model /// </summary> public void AddRace(RaceModel raceModel) { if (raceModel != null && !_races.Any(x => x.Id == raceModel.Id)) { _races.Add(raceModel); } }
public IActionResult ManageRaceProperties(string id) { model = new RaceModel(HttpContext.Session.GetString("dbusername"), HttpContext.Session.GetString("dbpassword")); ViewBag.HasProperties = model.GetRaceHasProperties(id); ViewBag.NotHasProperties = model.GetRaceNotHasProperties(id); ViewBag.Racekey = id; return(View()); }
/// <summary> /// Updates the model /// </summary> public void UpdateModel(RaceModel raceModel) { _raceModel = raceModel; Initialize(); OnPropertyChanged(""); }
private void PopulateRaceListBox() { RaceNames = RaceModel.GetNames(); foreach (string name in RaceNames) { RaceListBox.Items.Add(name); } }
public ActionResult Create(RaceModel race) { try { JavaScriptSerializer js = new JavaScriptSerializer(); LatLng[] listePoints = js.Deserialize <LatLng[]>(race.AjaxPoints); bool valid = true; if (ModelState.IsValid) { //Ajout de la course race = MgtRace.GetInstance().AddRace(race.ToBo()).ToModel(); //Ajout des points for (int i = 0; i < listePoints.Length; i++) { Point point = new Point(); point.Titre = "Titre " + i; point.Latitude = listePoints[i].lat; point.Longitude = listePoints[i].lng; point.Ordre = i; // VALEUR HARCODE => //TODO: modify if (i == 0) { point.TypePointId = 1; } else if (i == listePoints.Length - 1) { point.TypePointId = 2; } else { point.TypePointId = 4; //Correspond au KM } point.CourseId = race.Id; valid = valid && MgtPoint.GetInstance().AddPoint(point); } if (valid) { return(RedirectToAction("Index")); } else { return(View()); } } else { return(View()); } } catch (Exception ex) { Console.WriteLine(ex); return(View()); } }
public IActionResult Edit(int id) { var model = new RaceEditViewModel() { Race = RaceModel.GenerateRaceModelFromDTO(work.RaceRepository.GetDTO(id)) }; return(View(model)); }
public IActionResult Index() { var model = new RaceIndexViewModel() { Races = work.RaceRepository.GetAll().Select(e => RaceModel.GenerateRaceModelFromDTO(e)) }; return(View(model)); }
private CharacterCreateViewModel PopulateLists(CharacterCreateViewModel model) { model.Races = work.RaceRepository.GetAll().Select(e => RaceModel.GenerateRaceModelFromDTO(e)).ToList(); model.Classes = work.ClassRepository.GetAll().Select(e => ClassModel.GenerateClassModelFromDTO(e)).ToList(); model.BaseStats = work.BaseStatRepository.GetAll().Select(e => BaseStatModel.GeneralBaseStatModelFromDTO(e)).ToList(); model.Skills = work.SkillRepository.GetAll().Select(e => SkillModel.GenerateSkillModelFromDTO(e)); return(model); }
/// <summary> /// On initialization, preload the class names and set up an entry in the dictionary /// </summary> private void LoadRaceName() { RaceNames = RaceModel.GetNames(); Races = new SortedDictionary <string, RaceDataClass>(); foreach (string name in RaceNames) { Races.Add(name, new RaceDataClass(name)); } }
private void AddNewRequirementRecord() { RequirementModel reqModel; string tableName; string applyToName; reqModel = new RequirementModel(); tableName = comboCategory.SelectedItem.ToString(); applyToName = comboApplyTo.SelectedItem.ToString(); reqModel.TableNamesId = TableNamesModel.GetIdFromTableName(tableName); if (tableName == "Ability") { reqModel.ApplytoId = AbilityModel.GetIdFromName(applyToName); } else if (tableName == "Alignments") { reqModel.ApplytoId = AlignmentModel.GetIdFromName(applyToName); } else if (tableName == "Attribute") { reqModel.ApplytoId = AttributeModel.GetIdFromName(applyToName); } else if (tableName == "Class") { reqModel.ApplytoId = ClassModel.GetIdFromName(applyToName); } else if (tableName == "Enhancement") { reqModel.ApplytoId = GetEnhancementId(); } else if (tableName == "EnhancementSlot") { reqModel.ApplytoId = GetSlotId(); } else if (tableName == "Feat") { reqModel.ApplytoId = FeatModel.GetIdFromName(applyToName); } else if (tableName == "Race") { reqModel.ApplytoId = RaceModel.GetIdFromName(applyToName); } else if (tableName == "Skill") { reqModel.ApplytoId = SkillModel.GetIdFromName(applyToName); } else { Debug.WriteLine("Error: CategoryName isn't listed :: RequirementDialogClass: AddNewRequirement"); } reqModel.Save(); SelectedRequirementId = reqModel.Id; }
public PlayerCharacterModel() { PlayerClass = new ClassModel(); Archetype = new ArchetypeModel(); Background = new BackgroundModel(); Race = new RaceModel(); Alignment = new AlignmentModel(); AbilityScores = new List <PcAbilityScoreModel>(); SavingThrows = new List <int>(); PlayerSkills = new List <int>(); }
public async Task <IActionResult> Create([Bind("ID,Title,Local,EventDate,Type")] RaceModel raceModel) { if (ModelState.IsValid) { _context.Add(raceModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(raceModel)); }
public JsonResult Points(int id) { RaceModel result = MgtRace.GetInstance().GetRaceWithPoints(id).ToModel(false, true); result.Points = result.Points.OrderBy(x => x.Ordre).ToList(); if (result == null) { return(Json("")); } return(Json(result.Points, JsonRequestBehavior.AllowGet)); }
public IActionResult Index() { if (HttpContext.Session.GetString("dbusername") == null || HttpContext.Session.GetString("dbusername") == "guest") { return(RedirectToAction("Index", "Home")); } model = new RaceModel(HttpContext.Session.GetString("dbusername"), HttpContext.Session.GetString("dbpassword")); ViewBag.Races = model.GetRaces(); ViewBag.RacesNoOwner = model.GetRacesNoOwner(); return(View()); }
public GameObject[] ConstructCompetitors(RaceModel model, GameObject competitorPrefab) { int c; if (null != competitors) { for (c = 0; c < competitors.Length; c++) { Destroy(competitors[c]); } } competitors = new GameObject[SpeedModel.competitorCount]; for (c = 0; c < SpeedModel.competitorCount; c++) { Vector3 position = new Vector3(model.lanes[c], 0.25f, SpeedModel.competitors[c].z); competitors[c] = (GameObject) Instantiate( competitorPrefab, position, Quaternion.identity); competitors[c].SetActive(true); if (isVerbose) Debug.Log("RaceController.Construct: " + c + " position " + competitors[c].transform.position); } return competitors; }