[HttpGet("{id}")] //rout to get the id public DinoModel Get(int id) { var Dino = new DinoModel(); List <DinoModel> DinoID = Dino.DinoListGetter(); return(DinoID[id - 1]); }
public List <DinoModel> Put(int id, [FromBody] string name, string imageurl, string length, string weight, string habitat) { var dino = new DinoModel(); List <DinoModel> dinosaurs = dino.GetDinosaurs(); if (dinosaurs.Any(i => i.ID == id)) { dino = dinosaurs.SingleOrDefault(w => w.ID == id); dino.Name = name; dino.ImageURL = imageurl; dino.Length = length; dino.Weight = weight; dino.Habitat = habitat; } else { var newDino = new DinoModel { ID = id, Name = name, ImageURL = imageurl, Length = length, Weight = weight, Habitat = habitat }; dinosaurs.Add(newDino); } return(dinosaurs); }
public DinoModel Get(int id) { var dino = new DinoModel(); List <DinoModel> dinosaurs = dino.GetDinosaurs(); return(dinosaurs[id - 1]); }
public List <DinoModel> Get() { var dino = new DinoModel(); List <DinoModel> dinosaurs = dino.GetDinosaurs(); return(dinosaurs); }
public List <DinoModel> Get() //this will get all of the Dinos { var Dino = new DinoModel(); //list of dinoModel is now called Dinosaurs List <DinoModel> Dinosaurs = Dino.DinoListGetter(); return(Dinosaurs); }
public List <DinoModel> Delete(int id) { var dino = new DinoModel(); List <DinoModel> dinosaurs = dino.GetDinosaurs(); dino = dinosaurs.SingleOrDefault(i => i.ID == id); dinosaurs.Remove(dino); return(dinosaurs); }
public List <DinoModel> Post([FromBody] int id, string name, string imageurl, string length, string weight, string habitat) { var dino = new DinoModel(); List <DinoModel> dinosaurs = dino.GetDinosaurs(); var newDino = new DinoModel { ID = id, Name = name, ImageURL = imageurl, Length = length, Weight = weight, Habitat = habitat }; dinosaurs.Add(newDino); return(dinosaurs); }
public DinoModel ParseDinoExport(MemoryStream memoryStream) { DinoModel dino = new DinoModel(); dino.Stats = new StatModel(); using (var reader = new StreamReader(memoryStream, Encoding.UTF8)) { string line; while ((line = reader.ReadLine()) != null) { if (line.StartsWith("[")) { continue; } if (!line.Contains("=")) { continue; } var keyVal = line.Split('='); if (keyVal.Length < 2) { continue; } if (keyVal[0] == "DinoID1") { dino.Id1 = Convert.ToInt32(keyVal[1]); } else if (keyVal[0] == "DinoID2") { dino.Id2 = Convert.ToInt32(keyVal[1]); } else if (keyVal[0] == "DinoNameTag") { dino.DinoNameTag = keyVal[1]; } else if (keyVal[0] == "bIsFemale") { dino.IsFemale = Convert.ToBoolean(keyVal[1]); } else if (keyVal[0] == "DinoClass") { dino.DinoType = keyVal[1]; } else if (keyVal[0] == "bNeutered") { dino.IsNeutered = Convert.ToBoolean(keyVal[1]); } else if (keyVal[0] == "TamerString") { dino.TamedBy = keyVal[1]; } else if (keyVal[0] == "ImprinterName") { dino.ImpritedBy = keyVal[1]; } else if (keyVal[0] == "CharacterLevel") { dino.Level = int.Parse(keyVal[1]); } else if (keyVal[0] == "DinoImprintingQuality") { dino.DinoImprintQuality = float.Parse(keyVal[1]); } else if (keyVal[0] == "Health") { dino.Stats.Health = float.Parse(keyVal[1]); } else if (keyVal[0] == "Stamina") { dino.Stats.Stamina = float.Parse(keyVal[1]); } else if (keyVal[0] == "Torpidity") { dino.Stats.Torp = float.Parse(keyVal[1]); } else if (keyVal[0] == "Oxygen") { dino.Stats.Oxygen = float.Parse(keyVal[1]); } else if (keyVal[0] == "food") { dino.Stats.Food = float.Parse(keyVal[1]); } else if (keyVal[0] == "Weight") { dino.Stats.Weight = float.Parse(keyVal[1]); } else if (keyVal[0] == "Melee Damage") { dino.Stats.Melee = float.Parse(keyVal[1]); } else if (keyVal[0] == "Crafting Skill") { dino.Stats.CraftingSkill = float.Parse(keyVal[1]); } } } return(dino); }
private void removeDino(ref Dictionary <ulong, Dictionary <string, List <DinoModel> > > cache, ulong serverId, DinoModel dino) { var index = cache[serverId][dino.DinoType].FindIndex(c => c.uniqueID == dino.uniqueID); if (index == -1) { return; } cache[serverId][dino.DinoType].RemoveAt(index); }
public void RemoveDino(ulong serverId, DinoModel dino) => removeDino(ref cache, serverId, dino);
private void addDino(ref Dictionary <ulong, Dictionary <string, List <DinoModel> > > cache, ulong serverId, DinoModel dino) { if (!cache.ContainsKey(serverId)) { cache.Add(serverId, new Dictionary <string, List <DinoModel> >()); } if (!cache[serverId].ContainsKey(dino.DinoType)) { cache[serverId].Add(dino.DinoType, new List <DinoModel>() { dino }); } if (!cache[serverId][dino.DinoType].Exists(c => c.uniqueID == dino.uniqueID)) { cache[serverId][dino.DinoType].Add(dino); Console.WriteLine("adding"); } else { var id = cache[serverId][dino.DinoType].FindIndex(c => c.uniqueID == dino.uniqueID); cache[serverId][dino.DinoType].Add(dino); cache[serverId][dino.DinoType].RemoveAt(id); } Console.WriteLine(cache[serverId].Count()); }
public void AddDino(ulong serverId, DinoModel dino) => addDino(ref cache, serverId, dino);