Exemplo n.º 1
0
        public IActionResult Edit(int ID)
        {
            Treatment treatment = _treatmentService.FindByID(ID);
            Stay      stay      = _stayService.FindByID(treatment.StayID);
            var       vm        = new TreatmentViewModel()
            {
                Animal    = _animalService.FindByID(stay.AnimalID),
                Treatment = treatment,
                Stay      = stay
            };

            return(View(vm));
        }
Exemplo n.º 2
0
        public IActionResult PlaceAnimal(int ID)
        {
            var vm = new AnimalViewModel()
            {
                Lodgings = _lodgingService.ReturnAvailableLocations(ID), // Only get lodges with proper type & those that have space left.
                Animal   = _animalService.FindByID(ID),
                Stay     = _stayService.FindByID(ID),
                Lodge    = _lodgingService.FindByID(ID)
            };

            return(View(vm));
        }
Exemplo n.º 3
0
        public IActionResult Adopt(AdoptionViewModel AdoptionViewModel)
        {
            try
            {
                Console.WriteLine(AdoptionViewModel);
                Stay   stay   = _stayService.FindByID(AdoptionViewModel.Stay.ID);
                Animal animal = _animalService.FindByID(AdoptionViewModel.Animal.ID);

                stay.AdoptedBy    = AdoptionViewModel.User.Email;
                stay.Animal       = animal;
                stay.AdoptionDate = DateTime.Now;

                _stayService.AdoptAnimal(stay);

                return(Redirect("/Stay/Index"));
            }
            catch (Exception e)
            {
                Console.WriteLine("Error occured" + e); // TODO: use logger service for this
            }

            return(Redirect("/Stay/Index"));
        }
Exemplo n.º 4
0
        public IActionResult Details(int ID)
        {
            Stay stay = _stayService.FindByID(ID);

            return(View(stay));
        }
Exemplo n.º 5
0
        public IActionResult GetStay(int id)
        {
            Stay stay = _stayService.FindByID(id);

            return(Ok(stay));
        }