Exemplo n.º 1
0
        public async Task ReloadAsync(ValuteGetterService valuteGetter)
        {
            await dbContext.Insurances.LoadAsync();

            _insurances = await dbContext.Insurances.AsNoTracking().ToListAsync();

            _insurancesDto = _insurances.Select(x =>
            {
                var dto     = mapper.MapTo <Insurance, InsuranceDto>(x);
                dto.CostUSD = valuteGetter.GetUSDValue(x.Cost);
                dto.CostEUR = valuteGetter.GetEuroValue(x.Cost);
                return(dto);
            }).ToList();
        }
Exemplo n.º 2
0
        public async Task <IEnumerable <OrderDto> > GetAllOrders(int clientId, ValuteGetterService valuteGetter)
        {
            await dbContext.Orders.LoadAsync();

            var list = await(dbContext.Orders.
                             Where(x => x.ClientId == clientId && (x.OrderStatus == OrderStatus.Active || x.OrderStatus == OrderStatus.Completed)).
                             OrderBy(x => x.CreationDate)).
                       ToListAsync();

            foreach (var order in list)
            {
                await dbContext.Entry(order).Collection(x => x.Insurances).LoadAsync();

                await dbContext.Entry(order).Reference(x => x.Tour).LoadAsync();

                await dbContext.Entry(order).Reference(x => x.Client).LoadAsync();
            }

            return(list.Select(y =>
            {
                var inst = mapper.MapTo <Order, OrderDto>(y);
                inst.ClientDto = mapper.MapTo <Client, ClientDto>(y.Client);
                inst.FullCostEUR = valuteGetter.GetEuroValue(y.FullCost);
                inst.FullCostUSD = valuteGetter.GetUSDValue(y.FullCost);
                inst.InsuranceDtos = y.Insurances.Select(x =>
                {
                    var dto = mapper.MapTo <Insurance, InsuranceDto>(x);
                    dto.CostUSD = valuteGetter.GetUSDValue(x.Cost);
                    dto.CostEUR = valuteGetter.GetEuroValue(x.Cost);

                    return dto;
                }).ToList();

                var tour = dbContext.Tours.AsNoTracking().FirstOrDefault(x => x.Id == y.TourId);
                inst.TourDto = mapper.MapTo <Tour, TourDto>(tour);

                return inst;
            }));
        }
Exemplo n.º 3
0
        public void ShowOrderContract(OrderDto orderDto, ValuteGetterService valuteGetter, string path)
        {
            Dictionary <string, string>   stubs     = new Dictionary <string, string>();
            Dictionary <string, string[]> stubsColl = new Dictionary <string, string[]>();


            DateTime      endDate = orderDto.TourDto.StartDate.AddDays(orderDto.TourDto.DaysCount);
            StringBuilder insStr  = new StringBuilder();
            List <string> plList  = new List <string>();
            List <string> insList = new List <string>();


            stubs.Add("[Номер_заказа]", orderDto.Id.ToString());
            stubs.Add("[День]", orderDto.CreationDate.ToString("dd"));
            stubs.Add("[Месяц]", orderDto.CreationDate.ToString("MMMM"));
            stubs.Add("[Год]", orderDto.CreationDate.ToString("yyyy"));
            stubs.Add("[ФИО]", orderDto.ClientDto.Name);
            stubs.Add("[Дата_с]", orderDto.TourDto.StartDate.ToString("dd.MM.yyyy"));
            stubs.Add("[Дата_по]", endDate.ToString("dd.MM.yyyy"));
            stubs.Add("[Кол-во_дней]", orderDto.TourDto.DaysCount.ToString());
            stubs.Add("[Кол-во_туристов]", orderDto.PeopleCount.ToString());


            var list = orderDto.PlacementDtos.ToList();

            for (int i = 0; i < list.Count; i++)
            {
                var pl = list[i];

                string doc     = !pl.IsChildBefore14 ? pl.Pasport : pl.BirthDoc;
                string docName = !pl.IsChildBefore14 ? "паспорт" : "св-во. рождении";

                string line = $"{i+1}){pl.Fio}, {docName}: {doc}, каюта №: {pl.CabinDto.Id}, палуба: {pl.CabinDto.Deck}";
                plList.Add(line);
            }
            stubsColl.Add("[Туристы]", plList.ToArray());


            if (orderDto.HasIns)
            {
                var list1 = orderDto.InsuranceDtos.ToList();

                for (int i = 0; i < orderDto.InsuranceDtos.Count; i++)
                {
                    var    ins  = list1[i];
                    string line = $"{i + 1}) {ins.Name}";
                    insList.Add(line);
                }
            }
            else
            {
                insList.Add("нет");
            }

            stubsColl.Add("[Страховка]", insList.ToArray());

            stubs.Add("[Общая_стоимость]", orderDto.FullCost.ToString("0.##"));
            stubs.Add("[Общая_стоимостьUSD]", valuteGetter.GetUSDValue(orderDto.FullCost).ToString("0.##"));
            stubs.Add("[Общая_стоимостьEUR]", valuteGetter.GetEuroValue(orderDto.FullCost).ToString("0.##"));

            ShowDocument(stubs, path, stubsColl);
        }