public ActionResult Create(Walks Walk) { try { int counter = 0; foreach (int dog in Walk.Dogs) { _walkRepo.AddWalks(Walk, counter); counter++; } return(RedirectToAction("Index")); } catch { List <Dog> Dog = _dogRepo.GetAllDogs(); List <Walker> Walker = _walkerRepo.GetAllWalkers(); WalksViewModel vm = new WalksViewModel { Dog = Dog, Walker = Walker, Walk = new Walks() }; return(View(vm)); } }
// GET: WalksController/Create public ActionResult Create() { List <Dog> Dog = _dogRepo.GetAllDogs(); List <Walker> Walker = _walkerRepo.GetAllWalkers(); WalksViewModel vm = new WalksViewModel { Dog = Dog, Walker = Walker, Walk = new Walks() }; return(View(vm)); }
// GET: WalksController/Delete/5 public ActionResult Delete(int id) { List <Dog> Dog = _dogRepo.GetAllDogs(); List <Walker> Walker = _walkerRepo.GetAllWalkers(); List <Walks> walks = _walkRepo.GetAllWalks(); WalksViewModel vm = new WalksViewModel { Dog = Dog, Walker = Walker, AllWalks = walks }; return(View(vm)); }
public ActionResult Delete(WalksViewModel walk) { try { foreach (int walkId in walk.WalkIds) { _walkRepo.DeleteWalks(walkId); } return(RedirectToAction("Index")); } catch { return(View()); } }