Example #1
0
        public IEnumerable <ObjectToRentVM> GetObjectToRentFromUser(Guid ownerId)
        {
            IEnumerable <ObjectToRent> objectToRents = objectToRentRepository.Get();
            var otrVMs = from o in objectToRents where o.UserId == ownerId select new ObjectToRentVM()
            {
                AddedDate = o.AddedDate, ObjectToRentId = o.ObjectToRentId, Floor = o.Floor, OwnerNickName = userRepository.Get(ownerId).NickName
            };

            return(otrVMs);
        }
        public AdvDetails MapAdvDetails(Guid id)
        {
            ObjectToRent objectToRent = objectToRentRepository.Get(id);
            User         user         = userRepository.Get(objectToRent.UserId.Value);
            Location     location     = locationRepository.Get(objectToRent.LocationId.Value);
            List <EquipmentObjectToRent> equipments = equipmentObjectToRentRepository.Get().ToList().FindAll(x => x.ObjectToRentId == objectToRent.ObjectToRentId);
            AdvDetails advDetails = new AdvDetails()
            {
                Description = MakeDescription(objectToRent, location, equipments), AddDate = objectToRent.AddedDate, Address = location.City + " " + location.Address, email = user.EMail, Phone = user.PhoneNumber, Prize = objectToRent.Prize
            };

            return(advDetails);
        }
        public List <AdBasic> getAdBasics()
        {
            IEnumerable <ObjectToRent> objectToRents = objectToRentRepository.Get();
            IEnumerable <Location>     locations     = locationRepository.Get();
            List <AdBasic>             adBasics      = new List <AdBasic>();

            foreach (var item in objectToRents)
            {
                adBasics.Add(MapAdBasic(item, locations.ToList().Find(x => x.LocationId == item.LocationId)));
            }
            adBasics.Sort((x, y) => y.AddDate.CompareTo(x.AddDate));
            adBasics.Reverse();
            return(adBasics);
        }