Beispiel #1
0
 public void DeleteDog(int id)
 {
     using (UnitOfWork uow = new UnitOfWork())
     {
         Dog dog = uow.GetDogDAO().GetDogById(id);
         uow.GetDogDAO().DeleteDog(dog);
     }
 }
Beispiel #2
0
 public void UpdateDog(DogFM fm)
 {
     using (UnitOfWork uow = new UnitOfWork())
     {
         Dog dog = uow.GetDogDAO().GetDogById(fm.Id);
         dog.Name = fm.Name;
         dog.Age  = fm.Age;
         uow.GetDogDAO().UpdateDog(dog);
         Breed breed = uow.GetBreedDAO().GetBreedById(fm.BreedId);
         uow.GetDogDAO().UpdateDogBreed(dog, breed);
     }
 }
Beispiel #3
0
        public void SaveNewDog(DogFM fm)
        {
            Dog dog = new Dog();

            dog.Name = fm.Name;
            dog.Age  = fm.Age;
            using (UnitOfWork uow = new UnitOfWork())
            {
                Breed breed = uow.GetBreedDAO().GetBreedById(fm.BreedId);
                uow.GetDogDAO().CreateDog(dog, breed);
            }
        }
Beispiel #4
0
        public DogsVM GetDogsVM()
        {
            DogsVM vm = new DogsVM();

            using (UnitOfWork uow = new UnitOfWork())
            {
                foreach (Dog dog in uow.GetDogDAO().GetAllDogs())
                {
                    ViewDogVM dogVM = new ViewDogVM();
                    dogVM.Id    = dog.Id;
                    dogVM.Age   = dog.Age;
                    dogVM.Name  = dog.Name;
                    dogVM.Breed = uow.GetBreedDAO().GetBreedByDog(dog).Type;
                    vm.Dogs.Add(dogVM);
                }
            }
            return(vm);
        }
Beispiel #5
0
        public EditDogVM GetEditDogVM(int id)
        {
            EditDogVM vm = new EditDogVM();

            using (UnitOfWork uow = new UnitOfWork())
            {
                vm.Breeds = GetBreedVMs(uow);
                DogVM dogVM = new DogVM();
                Dog   dog   = uow.GetDogDAO().GetDogById(id);
                dogVM.Id   = id;
                dogVM.Age  = dog.Age;
                dogVM.Name = dog.Name;
                BreedVM breedVM = new BreedVM();
                Breed   breed   = uow.GetBreedDAO().GetBreedByDog(dog);
                breedVM.Id   = breed.Id;
                breedVM.Type = breed.Type;
                vm.Dog       = dogVM;
                vm.Breed     = breedVM;
            }
            return(vm);
        }