public static void Seed(IAnimalDataService service) { service.Initialise(); var c1 = service.Insert(new Animal { Name = "Rosie", Type = "Cat", Breed = "Bengal", Gender = 'F', DOB = DateTime.Parse("23/08/2019"), Description = "A young cat looking for love.", Image = "https://www.zooplus.co.uk/magazine/wp-content/uploads/2018/02/fotolia_82719975-768x582.jpg" }); var c2 = service.Insert(new Animal { Name = "Ralph", Type = "Dog", Breed = "Labrador", Gender = 'M', DOB = DateTime.Parse("11/05/2007"), Description = "An old dog looking for love.", Image = "https://www.thelabradorsite.com/wp-content/uploads/2018/09/Labrador-Retriever-LS-long.jpg" }); }
public static void Seed(IAnimalDataService service) { service.Initialise(); var a1 = service.Insert(new Animal { animalName = "Buster", animalType = "Dog", animalBreed = "Landseer/Collie", animalCharacteristics = "Ignorant, Loving, Fluffy, Cheeky", animalDOB = DateTime.Parse("11/10/2008"), animalGender = "Male", animalImage = "https://s3.amazonaws.com/filestore.rescuegroups.org/956/pictures/animals/8782/8782356/27376639_500x421.jpg" }); var a2 = service.Insert(new Animal { animalName = "Sylvie", animalType = "Cat", animalBreed = "Tabby", animalCharacteristics = "Sweet, timid", animalDOB = DateTime.Parse("11/10/2017"), animalGender = "Female", animalImage = "https://www.purina.co.uk/sites/g/files/mcldtz2481/files/2019-07/what_are_tabby_cats_3.jpg" }); }
public IActionResult Create(Animal obj) { if (ModelState.IsValid) { // check valid state service.Insert(obj); return(RedirectToAction("Index")); } else // not valid so redisplay { return(View(obj)); } }
public IActionResult Create(Animal obj) { if (ModelState.IsValid) { service.Insert(obj); return(RedirectToAction("Index")); } else { return(View(obj)); } }
public static void Seed(IAnimalDataService service) { service.Initialise(); var c1 = service.Insert(new Animals { AniName = "Rover", AniType = "Dog", AniBreed = "Alsatian", AniDoB = DateTime.Parse("23/09/2016"), AniDesc = "Brown and Black, Friendly", AniPic = "https://www.puppies.co.uk/wp-content/uploads/2018/03/gsd_88_43FP-wpcf_300x300.jpg" }); var c2 = service.Insert(new Animals { AniName = "Socks", AniType = "Cat", AniBreed = "Shorthair", AniDoB = DateTime.Parse("23/09/2016"), AniDesc = "Black body, White feet", AniPic = "https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcQCzBZtJlMh4tiHl_IXk1ZqNIphYleRuPcZhE6z1uz1qcq4buwE" }); var c3 = service.Insert(new Animals { AniName = "Nibbles", AniType = "Ferret", AniBreed = "Black Sable Mitt", AniDoB = DateTime.Parse("23/09/2016"), AniDesc = "Knows several tricks", AniPic = "https://www.coopsandcages.com.au/blog/oe-content/uploads/2014/02/3-Ferret-Black-Sable-Mitt_mini.jpg" }); var c4 = service.Insert(new Animals { AniName = "Flopsy", AniType = "Rabbit", AniBreed = "Mini Lop", AniDoB = DateTime.Parse("23/09/2016"), AniDesc = "Will always come when called", AniPic = "https://upload.wikimedia.org/wikipedia/commons/0/03/Miniature_Lop_-_Side_View.jpg" }); var c5 = service.Insert(new Animals { AniName = "Fly", AniType = "Dog", AniBreed = "German Shorthair Pointer", AniDoB = DateTime.Parse("23/09/2016"), AniDesc = "Very well trained, former hunting dog", AniPic = "https://i.pinimg.com/564x/4b/1a/3a/4b1a3a4f3ad46dd6202701da9a5630d9.jpg" }); var c6 = service.Insert(new Animals { AniName = "Monty", AniType = "Snake", AniBreed = "Burmese Python", AniDoB = DateTime.Parse("23/09/2016"), AniDesc = "Likes to be stroked", AniPic = "https://www.nationalgeographic.com/content/dam/animals/pictures/reptiles/b/burmese-python/burmese-python.jpg" }); }
public void TestInsert() { Animal animal = new Animal(); animal.Name = "rhys"; animal.Type = "cat"; animal.Breed = "bengal"; animal.Gender = 'M'; animal.DOB = DateTime.Parse("23 / 09 / 2016"); animal.Description = "Young cat"; animal.Image = "https://www.zooplus.co.uk/magazine/wp-content/uploads/2018/02/fotolia_82719975-768x582.jpg"; var returnedAnimal = service.Insert(animal); string animalName = returnedAnimal.Name; // Assert Assert.Equal("rhys", animalName); }
public void TestInsert() { ServiceSeeder.Seed(service); var animals = service.SelectAll(); var beforeCount = animals.Count(); var test = service.Insert(new Animals { AniName = "test", AniType = "test", AniBreed = "test", AniDoB = DateTime.Parse("01/01/2000"), AniDesc = "test", AniPic = "test" }); animals = service.SelectAll(); var afterCount = animals.Count(); Assert.Equal(beforeCount + 1, afterCount); }