void SearchPetByType() { Type type = TypeSelection(); Console.WriteLine($" The {type.ToString().ToLower()}s in the database:\n"); foreach (Pet pet in _petServ.GetPetByType(type)) { Console.WriteLine($" {pet.ID}. Name: {pet.Name}, BirthDate: {pet.BirthDate.ToShortDateString()}, Sold in {pet.SoldDate.ToShortDateString()}, Color: {pet.Color}, Previous Owner: {pet.PreviousOwner.FirstName} {pet.PreviousOwner.LastName}, Price: {pet.Price} DKK"); } Console.ReadLine(); StartUI(); }
public ActionResult <IEnumerable <Pet> > Type([FromQuery] Type type) { List <Pet> filteredList = _petService.GetPetByType(type); filteredList.ForEach(pet => pet.PreviousOwner.SelectMany(po => new List <Owner>() { new Owner() { ID = po.ID, FirstName = po.FirstName, LastName = po.LastName, Address = po.Address, PhoneNumber = po.PhoneNumber, Email = po.Email } })); filteredList.ForEach(pet => pet.PetColor.ForEach(pcol => pcol.Color.PetColor.Clear())); return(Ok(filteredList)); }
void AddNewPet() { int price, year, month, day; Type type = TypeSelection(); Console.Write($" Type the name of the {type}: "); string name = Console.ReadLine(); Console.WriteLine($" What color does {name} has?"); string color = Console.ReadLine(); Console.WriteLine($" How much {name} costs?"); int.TryParse(Console.ReadLine(), out price); Console.WriteLine($" When did {name} born?"); Console.WriteLine(" Year: "); int.TryParse(Console.ReadLine(), out year); Console.WriteLine(" Month: "); int.TryParse(Console.ReadLine(), out month); Console.WriteLine(" Day: "); int.TryParse(Console.ReadLine(), out day); DateTime birth = new DateTime(year, month, day); DateTime sold = DateTime.UtcNow; Pet p = new Pet() { ID = GetNextId(), Name = name, Color = color, BirthDate = birth, SoldDate = sold, Price = price }; _petServ.AddPet(p); Console.WriteLine($" You've added {name} to the database.\n\nPress Enter to continue..."); Console.ReadLine(); StartUI(); }