public ActionResult Edit(int id) { using (var ctx = new ApplicationDbContext()) { ViewBag.ShelterList = ctx.Shelters.Select (s => new SelectListItem() { Text = s.ShelterName, Value = s.ShelterId.ToString() } ).ToList(); } var service = new DogService(); var detail = service.GetDogById(id); var model = new DogEdit { DogId = detail.DogId, DogName = detail.DogName, DogBreed = detail.DogBreed, DogSex = detail.DogSex, DogWeight = detail.DogWeight, DogAge = detail.DogAge, DogPrice = detail.DogPrice, DogImage = detail.DogImage, ShelterId = detail.ShelterId }; return(View(model)); }
public ActionResult Details(int id) { var svc = new DogService(); var model = svc.GetDogById(id); return(View(model)); }
public string GetDogById(int?id) { string message; if (id.GetValueOrDefault() == default) { message = "You have not provided a valid id number for a dog"; } else { message = _dogService.GetDogById(id.Value); } return(message); }
public IActionResult Edit(int id) { var dog = service.GetDogById(id); return(View(dog)); }