Exemplo n.º 1
0
        public ActionResult Create(WalkFormViewModel vm)
        {
            vm.Walk.Duration     = 0;
            vm.Walk.WalkStatusId = 1;
            vm.Dogs = _dogsRepo.GetDogsByOwnerId(GetCurrentUserId());

            try
            {
                // TODO: Add insert logic here
                _walksRepo.AddWalk(vm.Walk);
                return(RedirectToAction("Details", "Owners", new { id = GetCurrentUserId() }));
            }
            catch
            {
                return(View(vm));
            }
        }
Exemplo n.º 2
0
        public ActionResult Create(Walks Walks)
        {
            try
            {
                _walksRepo.AddWalk(Walks);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                List <Walker> walkers = _walkerRepo.GetAllWalkers();
                List <Dog>    dogs    = _dogRepo.GetAllDogs();
                WalkFormModel vm      = new WalkFormModel()
                {
                    Walks   = new Walks(),
                    Dogs    = dogs,
                    Walkers = walkers
                };
                return(View(vm));
            }
        }
Exemplo n.º 3
0
        public ActionResult Create(AppointmentViewModel avm, int id)
        {
            try
            {
                _walksRepository.AddWalk(avm.Walk);
                return(RedirectToAction("Details", "Owners"));
            }
            catch (Exception ex)
            {
                Walker     walker  = _walkerRepository.GetWalkerById(id);
                int        ownerId = GetCurrentOwner();
                List <Dog> dogs    = _dogRepository.GetDogsByOwnerId(ownerId);

                avm = new AppointmentViewModel
                {
                    OwnerId      = ownerId,
                    Walker       = walker,
                    Doggos       = dogs,
                    ErrorMessage = "Oh no, seems something is wrong. Please ensure the form is filled out completely"
                };
                return(View(avm));
            }
        }