Пример #1
0
        /// <summary>
        /// Inits the sight default pic info.
        /// 得到每个景区一张缩略图
        /// </summary>
        /// <param name="si">The si.</param>
        /// <returns></returns>
        public List <iPow.Domain.Dto.Sys_PicInfoDto> GetSightDefaultPic(PagedList <DefaultSightInfoDto> si)
        {
            List <iPow.Infrastructure.Data.DataSys.Sys_PicInfo> spc = new List <Infrastructure.Data.DataSys.Sys_PicInfo>();

            if (si != null)
            {
                foreach (var i in si)
                {
                    var rand = new Random();
                    var temp = (from e in picInfoRepository.GetList() where e.ParkID == i.ParkID select e).Count();
                    if (temp > 0)
                    {
                        var toKip   = rand.Next(0, temp);
                        var tempPic = (from e in picInfoRepository.GetList()
                                       where e.ParkID == i.ParkID
                                       orderby e.ViewCount
                                       select e).Skip(toKip).Take(1).FirstOrDefault();
                        if (tempPic != null)
                        {
                            spc.Add(tempPic);
                        }
                    }
                }
            }
            return(spc.ToDto().ToList());
        }
        public void Can_MapFromProductOptionList_ToProductOptionDtoList()
        {
            //Prepare
            var productOptions = new List <ProductOption>()
            {
                new ProductOption()
                {
                    Id          = Guid.NewGuid(),
                    Name        = "Product Option 1",
                    Description = "Product Option Description 1"
                },
                new ProductOption()
                {
                    Id          = Guid.NewGuid(),
                    Name        = "Product Option 2",
                    Description = "Product Option Description 2"
                },
            };

            //Act
            var productOptionDtos = productOptions.ToDto();

            //Assert
            Assert.NotNull(productOptionDtos);
            Assert.Equal(2, productOptionDtos.Count());

            Assert.All(productOptionDtos, optionDto =>
            {
                var productOption = productOptions.SingleOrDefault(p => p.Id == optionDto.Id);
                Assert.NotNull(productOption);
                Assert.Equal(productOption.Name, optionDto.Name);
                Assert.Equal(productOption.Description, optionDto.Description);
            });
        }
        public void Should_Transform_IEnumerableOfText_To_IEnumerableOfTextModel()
        {
            var expected = new List <TextModel>()
            {
                new TextModel()
                {
                    Language = _languages[0], Value = "sk1.fr"
                },
                new TextModel()
                {
                    Language = _languages[1], Value = "sk1.en"
                }
            };

            var act = new List <Text>()
            {
                new Text()
                {
                    Language = _languages[0], Value = "sk1.fr"
                },
                new Text()
                {
                    Language = _languages[1], Value = "sk1.en"
                }
            };

            var result = act.ToDto();

            AssertExtension.CompareIEnumerable(expected, result,
                                               (x, y) => x.Language == y.Language && x.Value == y.Value);
        }
Пример #4
0
        /// <summary>
        /// Gets the details of all payments made to a merchant.
        /// </summary>
        /// <param name="merchantId">The merchant id</param>
        /// <returns>List of PaymentItems</returns>
        public async Task <List <PaymentItem> > GetPaymentsByMerchantIdAsync(MerchantId merchantId)
        {
            await using PaymentControllerDbContext context = DbContextProvider.Create();

            List <Model.PaymentItem> payments = await context.Payments.Include(c => c.PaymentCard).Include(p => p.PaymentCustomer).Where(
                p => p.PaymentMerchant.Equals(new Model.Merchant()
            {
                MerchantId = merchantId.UUID
            })).ToListAsync().ConfigureAwait(false);

            return(payments.ToDto());
        }
Пример #5
0
        public static VisitDto ToDtoListPicture(this Visit visit)
        {
            List <ProfilePicture> tmp = visit.ProfilePictures.ToList();

            return(new VisitDto()
            {
                ID = visit.Id,
                Date = visit.Date,
                NbPasses = visit.NbPasses,
                ProfilePicture = tmp.ToDto(),
                PersonVisit = visit.Person.ToDto()
            });
        }
Пример #6
0
        public IEnumerable <ScopeDto> GetAll()
        {
            using (var context = RepositoriesFactory.CreateContext())
            {
                var scopes    = new List <Scope>();
                var rsRepo    = RepositoriesFactory.GetRessourceServerRepository(context);
                var scopeRepo = RepositoriesFactory.GetScopeRepository(context);

                var validRs = rsRepo.GetAll().Where(rs => rs.IsValid.Equals(true)).Select(rs => rs.Id).ToList();

                scopes = scopeRepo.GetAll().Where(s => validRs.Contains(s.RessourceServerId)).ToList();

                return(scopes.ToDto());
            }
        }
Пример #7
0
        public static OrderDto ToDto(this OrderSummary order, Customer customer, List <Entry> entries)
        {
            double totalBruttoPrice = 0;

            foreach (Entry entry in entries)
            {
                totalBruttoPrice += entry.Amount * entry.BruttoPrice;
            }

            return(new OrderDto
                   (
                       order.Id,
                       customer.ToDto(),
                       entries.ToDto(),
                       order.Status,
                       totalBruttoPrice,
                       order.SubmittedDate.Ticks,
                       order.DeliveredDate.Ticks
                   ));
        }
        public void Can_MapFromProductList_ToProductDtoList()
        {
            //Prepare
            var products = new List <Product>()
            {
                new Product()
                {
                    Id            = Guid.NewGuid(),
                    Name          = "Product 1",
                    Description   = "Product Description 1",
                    Price         = 100,
                    DeliveryPrice = 10
                },
                new Product()
                {
                    Id            = Guid.NewGuid(),
                    Name          = "Product 2",
                    Description   = "Product Description 2",
                    Price         = 200,
                    DeliveryPrice = 220
                }
            };

            //Act
            var productDtos = products.ToDto();

            //Assert
            Assert.NotNull(productDtos);
            Assert.Equal(2, productDtos.Count());

            Assert.All(productDtos, productDto =>
            {
                var product = products.SingleOrDefault(p => p.Id == productDto.Id);
                Assert.NotNull(product);
                Assert.Equal(product.Name, productDto.Name);
                Assert.Equal(product.Description, productDto.Description);
                Assert.Equal(product.Price, productDto.Price);
                Assert.Equal(product.DeliveryPrice, productDto.DeliveryPrice);
            });
        }
Пример #9
0
        public static UserDetails ToDto(this User user, Team team = null, List <Asset> assets = null)
        {
            var resultUser = new UserDetails
            {
                Id          = user.PK,
                Name        = user.Name,
                DateOfBirth = user.DateOfBirth,
                EmailId     = user.EmailId
            };

            if (team != null)
            {
                resultUser.Team = team.ToDto();
            }

            if (assets != null)
            {
                resultUser.Assets = assets.ToDto();
            }

            return(resultUser);
        }
Пример #10
0
        /// <summary>
        /// Gets the hotel around sight by lat.
        /// </summary>
        /// <param name="cityName">Name of the city.</param>
        /// <param name="lat">The lat.</param>
        /// <param name="lon">The lon.</param>
        /// <param name="take">The take.</param>
        /// <returns></returns>
        public List <iPow.Domain.Dto.Sys_SightInfoDto> GetHotelAroundSightByLat(string cityName, double lat, double lon, int take)
        {
            cityName = cityName.Replace("市", "");
            List <iPow.Infrastructure.Data.DataSys.Sys_SightInfo> res = new List <Sys_SightInfo>();
            //在数据库中 按 要添加景区的城市 选景区
            var sightList = sightInfoRepository.GetList(e => e.Latitude != 0)
                            .Where(e => e.Longitude != 0)
                            .Where(e => e.City.Contains(cityName));

            if (sightList != null && sightList.Count() > 0)
            {
                foreach (var item in sightList)
                {
                    //算周边景区,
                    if (CirPoint(lat, lon, (double)item.Latitude, (double)item.Longitude, 0.1))
                    {
                        res.Add(item);
                    }
                }
            }
            res = res.OrderBy(e => e.ViCount).Take(take).ToList();
            return(res.ToDto().ToList());
        }
        public void Should_Transform_IEnumerableOfTextModel_To_IEnumerableOfText()
        {
            var textValue = new List <string>()
            {
                "txt1", "txt2"
            };
            var expected = new List <Text>()
            {
                new Text()
                {
                    Language = _languages[0], Value = textValue[0]
                },
                new Text()
                {
                    Language = _languages[1], Value = textValue[1]
                }
            };

            IEnumerable <TextModel> act = new List <TextModel>()
            {
                new TextModel()
                {
                    Language = _languages[0], Value = textValue[0]
                },
                new TextModel()
                {
                    Language = _languages[1], Value = textValue[1]
                }
            };

            AssertExtension.CompareIEnumerable(expected, act.ToDto(_languages),
                                               (x, y) => x.Language == y.Language && x.Value == y.Value);

            AssertExtension.CompareIEnumerable(new List <Text>(), new List <TextModel>().ToDto(_languages),
                                               (x, y) => x.Language == y.Language && x.Value == y.Value);
        }
Пример #12
0
 /// <summary>
 /// Gets the hotel around sight by lat.
 /// </summary>
 /// <param name="cityName">Name of the city.</param>
 /// <param name="lat">The lat.</param>
 /// <param name="lon">The lon.</param>
 /// <param name="take">The take.</param>
 /// <returns></returns>
 public List<iPow.Domain.Dto.Sys_SightInfoDto> GetHotelAroundSightByLat(string cityName, double lat, double lon, int take)
 {
     cityName = cityName.Replace("市", "");
     List<iPow.Infrastructure.Data.DataSys.Sys_SightInfo> res = new List<Sys_SightInfo>();
     //在数据库中 按 要添加景区的城市 选景区
     var sightList = sightInfoRepository.GetList(e => e.Latitude != 0)
         .Where(e => e.Longitude != 0)
         .Where(e => e.City.Contains(cityName));
     if (sightList != null && sightList.Count() > 0)
     {
         foreach (var item in sightList)
         {
             //算周边景区,
             if (CirPoint(lat, lon, (double)item.Latitude, (double)item.Longitude, 0.1))
             {
                 res.Add(item);
             }
         }
     }
     res = res.OrderBy(e => e.ViCount).Take(take).ToList();
     return res.ToDto().ToList();
 }
Пример #13
0
        public async Task <IEnumerable <MerchandiseDto> > GetMerchandises()
        {
            List <Merchandise> merchandises = await Task.Factory.StartNew(() => _merchandiseRepository.Get().ToList());

            return(merchandises.ToDto());
        }
Пример #14
0
 /// <summary>
 /// Inits the sight default pic info.
 /// 得到每个景区一张缩略图
 /// </summary>
 /// <param name="si">The si.</param>
 /// <returns></returns>
 public List<Miaow.Domain.Dto.Sys_PicInfoDto> GetSightDefaultPic(PagedList<DefaultSightInfoDto> si)
 {
     List<Miaow.Infrastructure.Data.DataSys.Sys_PicInfo> spc = new List<Infrastructure.Data.DataSys.Sys_PicInfo>();
     if (si != null)
     {
         foreach (var i in si)
         {
             var rand = new Random();
             var temp = (from e in picInfoRepository.GetList() where e.ParkID == i.ParkID select e).Count();
             if (temp > 0)
             {
                 var toKip = rand.Next(0, temp);
                 var tempPic = (from e in picInfoRepository.GetList()
                                where e.ParkID == i.ParkID
                                orderby e.ViewCount
                                select e).Skip(toKip).Take(1).FirstOrDefault();
                 if (tempPic != null)
                 {
                     spc.Add(tempPic);
                 }
             }
         }
     }
     return spc.ToDto().ToList();
 }