public IActionResult Create(Animals model) { if (ModelState.IsValid) { var maxId = dogRepository.GetDogs().Max(x => x.Id) + 1; model.Id = maxId; dogRepository.AddDog(model); return(RedirectToAction("List")); } return(View(model)); }
public ActionResult Create(Dog dog) { try { _dogRepo.AddDog(dog); return(RedirectToAction("Index")); } catch (Exception ex) { return(View(dog)); } }
public ActionResult Create(DogFormViewModel vm) { try { _dogRepo.AddDog(vm.Dog); return(RedirectToAction("Index")); } catch { return(View(vm)); } }
public ActionResult Create(Dog dog) { try { dog.OwnerId = GetCurrentUserId(); _dogRepo.AddDog(dog); return(RedirectToAction("Index")); } catch { return(View(dog)); } }
public ActionResult Create(DogFormViewModel vm) { try { vm.Dog.OwnerId = GetCurrentUserId(); _dogRepo.AddDog(vm.Dog); return(RedirectToAction("Index")); } catch (Exception ex) { return(View(vm.Dog)); } }
public ActionResult Create(Dog dog) { try { // update the dogs OwnerId to the current user's Id dog.OwnerId = GetCurrentUserId(); _dogRepo.AddDog(dog); return(RedirectToAction("Index")); } catch (Exception ex) { return(View(dog)); } }
public Dog AddDog(Dog Dog) { return(_dogRepository.AddDog(Dog)); }