public IEnumerable <Pet> GetPets()
 {
     return(PetRepository.GetAll());
 }
Exemple #2
0
        public static List <PetData> GetPets()
        {
            PetRepository       petRep      = new PetRepository();
            KindRepository      kindRep     = new KindRepository();
            BreedRepository     breedRep    = new BreedRepository();
            UserRepository      userRep     = new UserRepository();
            UserTypeRepository  userTypeRep = new UserTypeRepository();
            OperationRepository operRep     = new OperationRepository();

            List <PhotoData> photos = GetPhotos();

            List <PetData> pets = new List <PetData>();

            petRep.GetAll().ToList().ForEach(x => pets.Add(new PetData
            {
                Id           = x.Id,
                Nickname     = x.Nickname,
                KindId       = x.KindId,
                BreedId      = x.BreedId,
                Kind         = kindRep.Get(x.KindId).Name,
                Breed        = breedRep.Get(x.BreedId).Name,
                Conditions   = x.Conditions,
                ArrivalDate  = x.ArrivalDate,
                Color        = x.Color,
                HealthStatus = x.HealthStatus,
                Photos       = photos.Where(k => k.PetId == x.Id).ToList()
            }));

            List <OperationData> op = new List <OperationData>(operRep.GetAll().ToList().Select(x => new OperationData
            {
                Id            = x.Id,
                PetId         = x.PetId,
                OperationDate = x.OperationDate,
                UserId        = x.UserId
            }));

            List <UserData> users = new List <UserData>();

            userRep.GetAll().ToList().ForEach(x => users.Add(new UserData
            {
                Id       = x.Id,
                Username = x.Username,
                Password = x.Password,
                UserType = new UserTypeData
                {
                    Id   = userTypeRep.Get(x.UserTypeId).Id,
                    Name = userTypeRep.Get(x.UserTypeId).Name
                },
                UserTypeId  = x.UserTypeId,
                FullName    = x.FullName,
                Address     = x.Address,
                PhoneNumber = x.PhoneNumber
            }));

            op.ForEach(x =>
                       pets.Where(p => p.Id == x.PetId).ToList()
                       .ForEach(pp => pp.User = users.FirstOrDefault(u => u.Id == x.UserId)));


            return(pets);
        }
        public ViewResult Index()
        {
            var model = petRepo.GetAll(); //pets.Values.ToList();

            return(View(model));
        }
        public ViewResult Index()
        {
            var model = petRepo.GetAll();

            return(View(model));
        }
Exemple #5
0
 // GET: api/Pet
 public IEnumerable <Pet> Get()
 {
     return(_rep.GetAll());
 }