public List <DinosaurModel> Put(int id, [FromBody] string name, string size, string weight, string period, string habitats) { var dino = new DinosaurModel(); var listofDinos = dino.GetDinosaurs(); if (listofDinos.Any(i => i.ID == id)) { dino = listofDinos.SingleOrDefault(x => x.ID == id); dino.Name = name; dino.Size = size; dino.Weight = weight; dino.Period = period; dino.Habitats = habitats; } else { var newDino = new DinosaurModel { ID = listofDinos.Count + 1, Name = name, Size = size, Weight = weight, Period = period, Habitats = habitats }; listofDinos.Add(newDino); } return(listofDinos); }
public DinosaurModel Get(int id) { var dino = new DinosaurModel(); List <DinosaurModel> dinos = dino.GetDinosaurs(); return(dinos[id - 1]); }
public List <DinosaurModel> Get() { var dino = new DinosaurModel(); List <DinosaurModel> dinos = dino.GetDinosaurs(); return(dinos); }
public List <DinosaurModel> Delete(int id) { var dino = new DinosaurModel(); var listofDinos = dino.GetDinosaurs(); dino = listofDinos.SingleOrDefault(i => i.ID == id); listofDinos.Remove(dino); return(listofDinos); }
public List <DinosaurModel> Post([FromBody] string name, string size, string weight, string period, string habitats) { var dino = new DinosaurModel(); var listofDinos = dino.GetDinosaurs(); var newDino = new DinosaurModel { ID = listofDinos.Count + 1, Name = name, Size = size, Weight = weight, Period = period, Habitats = habitats }; listofDinos.Add(newDino); return(listofDinos); }