Exemplo n.º 1
0
 private void PasswordBoxKeyUp(object sender, KeyRoutedEventArgs e)
 {
     if (Helper.IsEnterKey(e))
     {
         VendorSearch.Focus(FocusState.Programmatic);
     }
 }
Exemplo n.º 2
0
        private async Task <VendorSearch> GetSearchAsync(VendorDto vendor)
        {
            var countries = new List <string>();
            var cities    = new List <string>();
            var streets   = new List <string>();

            if (vendor.Addresses != null && vendor.Addresses.Any())
            {
                var countriesIds = vendor.Addresses.Select(a => a.CountryId)
                                   .Distinct()
                                   .ToList();
                var citiesIds = vendor.Addresses.Select(a => a.CityId)
                                .Distinct()
                                .ToList();
                streets = vendor.Addresses.Select(a => a.Street).ToList();

                var locations = (await _locationService.GetByIdsAsync(countriesIds)).ToList();
                countries = locations.Select(location => location.Country).ToList();
                cities    = locations.SelectMany(location => location.Cities
                                                 .Where(c => citiesIds.Contains(c.Id))
                                                 .Select(c => c.Name))
                            .ToList();
            }

            var categoriesIds   = new List <Guid>();
            var categoriesNames = new List <string>();
            var tagsIds         = new List <Guid>();
            var tagsNames       = new List <string>();
            var conditions      = new List <string>();

            if (vendor.Discounts != null && vendor.Discounts.Any())
            {
                var discounts = vendor.Discounts.ToList();
                conditions = discounts.Select(d => d.Conditions).ToList();

                categoriesIds = discounts.Select(c => c.CategoryId)
                                .Distinct()
                                .ToList();
                categoriesNames = (await _categoryService.GetByIdsAsync(categoriesIds))
                                  .Select(c => c.Name)
                                  .ToList();

                tagsIds = discounts.SelectMany(d => d.TagsIds ?? new List <Guid>())
                          .Distinct()
                          .ToList();
                tagsNames = (await _tagService.GetByIdsAsync(tagsIds))
                            .Select(t => t.Name)
                            .ToList();
            }

            var search = new VendorSearch
            {
                Id            = vendor.Id,
                Discounts     = conditions,
                Vendor        = vendor.Name,
                Categories    = categoriesNames,
                Tags          = tagsNames,
                Countries     = countries,
                Cities        = cities,
                Streets       = streets,
                CategoriesIds = categoriesIds,
                TagsIds       = tagsIds,
                Addresses     = _mapper.Map <IEnumerable <Address> >(vendor.Addresses).ToList()
            };

            return(search);
        }
Exemplo n.º 3
0
        private void InitializeData()
        {
            _location = new LocationDto
            {
                Id     = Guid.NewGuid(),
                Cities = new List <CityDto>
                {
                    new CityDto
                    {
                        Id   = Guid.NewGuid(),
                        Name = "Minsk"
                    }
                },
                Country = "Belarus"
            };

            var categoryId = Guid.NewGuid();
            var tagId      = Guid.NewGuid();

            _user = new User
            {
                Id       = Guid.NewGuid(),
                IsActive = true,
                Address  = new Address
                {
                    CityId    = _location.Cities[0].Id,
                    CountryId = _location.Id,
                    Street    = "g"
                },
                TagNotifications = new List <Guid> {
                    tagId
                },
                CategoryNotifications = new List <Guid> {
                    categoryId
                },
                AllNotificationsAreOn       = true,
                NewVendorNotificationIsOn   = true,
                NewDiscountNotificationIsOn = true
            };

            _vendor = new VendorSearch
            {
                Id        = Guid.NewGuid(),
                Vendor    = "Vendor",
                Addresses = new List <Address>
                {
                    new Address
                    {
                        Id        = 1,
                        CityId    = _location.Cities[0].Id,
                        CountryId = _location.Id,
                        Street    = "street"
                    }
                },
                CategoriesIds = new List <Guid>
                {
                    categoryId
                },
                TagsIds = new List <Guid>
                {
                    tagId
                }
            };

            _discount = new Discount
            {
                Id        = Guid.NewGuid(),
                Addresses = new List <Address>
                {
                    _vendor.Addresses.ElementAt(0)
                },
                CategoryId = categoryId,
                Conditions = "Conditions",
                TagsIds    = new List <Guid> {
                    tagId
                },
                VendorId   = _vendor.Id,
                VendorName = _vendor.Vendor,
                PromoCode  = "new promo code",
                StartDate  = DateTime.UtcNow.Date,
                EndDate    = DateTime.UtcNow.Date
            };

            var notifications = new List <Notification>
            {
                new Notification
                {
                    Id        = Guid.NewGuid(),
                    UserId    = _user.Id,
                    Date      = DateTime.Now,
                    IsRead    = false,
                    SubjectId = Guid.NewGuid(),
                    Type      = NotificationType.Vendor
                },
                new Notification
                {
                    Id        = Guid.NewGuid(),
                    UserId    = _user.Id,
                    Date      = DateTime.Now,
                    IsRead    = true,
                    SubjectId = Guid.NewGuid(),
                    Type      = NotificationType.Discount
                },
                new Notification
                {
                    Id     = Guid.NewGuid(),
                    UserId = Guid.NewGuid(),
                    Date   = DateTime.Now,
                    IsRead = false
                },
            };

            Data.AddRange(notifications);
        }