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));
        }
Exemple #2
0
 public ActionResult Create(Dog dog)
 {
     try
     {
         _dogRepo.AddDog(dog);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(View(dog));
     }
 }
Exemple #3
0
        public ActionResult Create(DogFormViewModel vm)
        {
            try
            {
                _dogRepo.AddDog(vm.Dog);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View(vm));
            }
        }
Exemple #4
0
 public ActionResult Create(Dog dog)
 {
     try
     {
         dog.OwnerId = GetCurrentUserId();
         _dogRepo.AddDog(dog);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(dog));
     }
 }
Exemple #5
0
        public ActionResult Create(DogFormViewModel vm)
        {
            try
            {
                vm.Dog.OwnerId = GetCurrentUserId();
                _dogRepo.AddDog(vm.Dog);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View(vm.Dog));
            }
        }
Exemple #6
0
        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));
            }
        }
Exemple #7
0
 public Dog AddDog(Dog Dog)
 {
     return(_dogRepository.AddDog(Dog));
 }