public void BatchTest()
        {
            var artistList = new List <Artist>(new Artist[] {
                new Artist()
                {
                    FirstName = "Artist1", MiddleName = "group1"
                },
                new Artist()
                {
                    FirstName = "Artist2", MiddleName = "group2"
                },
                new Artist()
                {
                    FirstName = "Artist3", MiddleName = "group1"
                },
                new Artist()
                {
                    FirstName = "Artist4", MiddleName = "group2"
                },
                new Artist()
                {
                    FirstName = "Artist5", MiddleName = "group1"
                },
            });


            //Insert Batch
            _artistRepo.Add(artistList);

            var count = _artistRepo.Count();

            Assert.AreEqual(count, artistList.Count);

            foreach (Artist artist in artistList)
            {
                Assert.AreNotEqual(new string('0', 24), artist.Id);
            }


            //Update Batch
            foreach (var artist in artistList)
            {
                artist.LastName = artist.FirstName;
            }

            _artistRepo.Update(artistList);

            foreach (var artist in artistList)
            {
                Assert.AreEqual(artist.FirstName, artist.LastName);
            }

            //Delete by criteria
            _artistRepo.Delete(a => a.MiddleName.StartsWith("group1"));

            var countAfterDel = _artistRepo.Count();

            Assert.AreEqual(countAfterDel, 2);
        }
示例#2
0
        public IHttpActionResult PostQuery(
            string collectionName,
            RemoteMongoQuery remoteMongoQuery)
        {
            var count = _mongoRepository.Count(collectionName, remoteMongoQuery.Query);

            var pageData = new Page
            {
                Current = remoteMongoQuery.Page.GetValueOrDefault(1),
                Size    = remoteMongoQuery.PageSize.GetValueOrDefault(10),
            }.Calculate(count);

            return(Ok(_mongoRepository.Find(
                          collectionName,
                          remoteMongoQuery.Query,
                          pageData.Size,
                          pageData.Skip,
                          remoteMongoQuery.Fields,
                          remoteMongoQuery.SortBy)));
        }
示例#3
0
        public async void SaveAllResource(ResourceData data)
        {
            if (await _repository.Count() > 0)
            {
                await _repository.DeleteAll();
            }
            var resList = data.ResourceContents.Select(a => new Resource()
            {
                ResourceValue = a.Value,
                ResourceName  = a.Name
            }).ToList();

            resList.Add(new Resource()
            {
                ResourceName  = "BusinessLinkQr",
                ResourceValue = "{0} is connected to your business now"
            });
            resList.Add(new Resource()
            {
                ResourceName  = "BusinessLinkEmail",
                ResourceValue = "{0} has sent you business link request"
            });
            resList.Add(new Resource()
            {
                ResourceName  = "BusinessJoinEmail",
                ResourceValue = "{0} has accepted your link request"
            });
            resList.Add(new Resource()
            {
                ResourceName  = "AssignProjectMessage",
                ResourceValue = "{0} has assigned you a new project"
            });
            resList.Add(new Resource()
            {
                ResourceName  = "AssignProjectActivityMessage",
                ResourceValue = "{0} has assigned you a project activity."
            });
            await _repository.Add(resList);

            var mongoMigrator = new Hub3cMongoMigrator(_repository);
        }
示例#4
0
        public void BatchTest()
        {
            var sliderList = new List <Slider>(new Slider[] {
                new Slider()
                {
                    ImageSrc = "ImageSrc1", IsActive = true
                },
                new Slider()
                {
                    ImageSrc = "ImageSrc2", IsActive = false
                },
                new Slider()
                {
                    ImageSrc = "ImageSrc3", IsActive = true
                },
                new Slider()
                {
                    ImageSrc = "ImageSrc4", IsActive = false
                },
                new Slider()
                {
                    ImageSrc = "ImageSrc5", IsActive = true
                },
            });

            //Insert Batch
            _sliderRepo.Add(sliderList);

            var count = _sliderRepo.Count();

            Assert.AreEqual(count, sliderList.Count);

            foreach (Slider slider in sliderList)
            {
                Assert.AreNotEqual(new string('0', 24), slider.Id);
            }


            //Update Batch
            var counter = 1;

            foreach (var slider in sliderList)
            {
                slider.ImageSrc = "ImageSrc1" + counter;
                counter++;
            }

            _sliderRepo.Update(sliderList);

            counter = 1;
            foreach (var slider in sliderList)
            {
                Assert.AreEqual(slider.ImageSrc, "ImageSrc1" + counter);
                counter++;
            }

            //Delete by criteria
            _sliderRepo.Delete(a => a.IsActive.Equals(true));

            var countAfterDel = _sliderRepo.Count();

            Assert.AreEqual(countAfterDel, 2);
        }
示例#5
0
        public void BatchTest()
        {
            var imageList = new List <Image>(new Image[] {
                new Image()
                {
                    Name = "Image1", Link = "link1"
                },
                new Image()
                {
                    Name = "Image2", Link = "link2"
                },
                new Image()
                {
                    Name = "Image3", Link = "link1"
                },
                new Image()
                {
                    Name = "Image4", Link = "link2"
                },
                new Image()
                {
                    Name = "Image5", Link = "link1"
                },
            });


            //Insert Batch
            _imageRepo.Add(imageList);

            var count = _imageRepo.Count();

            Assert.AreEqual(count, imageList.Count);

            foreach (Image image in imageList)
            {
                Assert.AreNotEqual(new string('0', 24), image.Id);
            }


            //Update Batch
            var counter = 1;

            foreach (var image in imageList)
            {
                image.Name = "Image1" + counter;
                counter++;
            }

            _imageRepo.Update(imageList);

            counter = 1;
            foreach (var image in imageList)
            {
                Assert.AreEqual(image.Name, "Image1" + counter);
                counter++;
            }

            //Delete by criteria
            _imageRepo.Delete(a => a.Link.StartsWith("link1"));

            var countAfterDel = _imageRepo.Count();

            Assert.AreEqual(countAfterDel, 2);
        }
示例#6
0
        public void BatchTest()
        {
            var socialList = new List <Social>(new Social[] {
                new Social()
                {
                    Name = "FullName1", Alt = "text1"
                },
                new Social()
                {
                    Name = "FullName2", Alt = "text2"
                },
                new Social()
                {
                    Name = "FullName3", Alt = "text1"
                },
                new Social()
                {
                    Name = "FullName4", Alt = "text2"
                },
                new Social()
                {
                    Name = "FullName5", Alt = "text1"
                },
            });

            //Insert Batch
            _socialRepo.Add(socialList);

            var count = _socialRepo.Count();

            Assert.AreEqual(count, socialList.Count);

            foreach (Social social in socialList)
            {
                Assert.AreNotEqual(new string('0', 24), social.Id);
            }


            //Update Batch
            var counter = 1;

            foreach (var social in socialList)
            {
                social.Name = "FullName1" + counter;
                counter++;
            }

            _socialRepo.Update(socialList);

            counter = 1;
            foreach (var message in socialList)
            {
                Assert.AreEqual(message.Name, "FullName1" + counter);
                counter++;
            }

            //Delete by criteria
            _socialRepo.Delete(a => a.Alt.StartsWith("text1"));

            var countAfterDel = _socialRepo.Count();

            Assert.AreEqual(countAfterDel, 2);
        }
        public void BatchTest()
        {
            var settingList = new List <Setting>(new Setting[] {
                new Setting()
                {
                    ImageLocation = "ImageLocation1", Type = 1
                },
                new Setting()
                {
                    ImageLocation = "ImageLocation2", Type = 2
                },
                new Setting()
                {
                    ImageLocation = "ImageLocation3", Type = 1
                },
                new Setting()
                {
                    ImageLocation = "ImageLocation4", Type = 2
                },
                new Setting()
                {
                    ImageLocation = "ImageLocation5", Type = 1
                },
            });

            //Insert Batch
            _settingsRepo.Add(settingList);

            var count = _settingsRepo.Count();

            Assert.AreEqual(count, settingList.Count);

            foreach (Setting setting in settingList)
            {
                Assert.AreNotEqual(new string('0', 24), setting.Id);
            }


            //Update Batch
            var counter = 1;

            foreach (var setting in settingList)
            {
                setting.ImageLocation = "ImageLocation1" + counter;
                counter++;
            }

            _settingsRepo.Update(settingList);

            counter = 1;
            foreach (var setting in settingList)
            {
                Assert.AreEqual(setting.ImageLocation, "ImageLocation1" + counter);
                counter++;
            }

            //Delete by criteria
            _settingsRepo.Delete(a => a.Type.Equals(1));

            var countAfterDel = _settingsRepo.Count();

            Assert.AreEqual(countAfterDel, 2);
        }
示例#8
0
        public void BatchTest()
        {
            var labelList = new List <Label>(new Label[] {
                new Label()
                {
                    LabelName = "Label1", Text = "text1"
                },
                new Label()
                {
                    LabelName = "Label2", Text = "text2"
                },
                new Label()
                {
                    LabelName = "Label3", Text = "text1"
                },
                new Label()
                {
                    LabelName = "Label4", Text = "text2"
                },
                new Label()
                {
                    LabelName = "Label5", Text = "text1"
                },
            });


            //Insert Batch
            _labelRepo.Add(labelList);

            var count = _labelRepo.Count();

            Assert.AreEqual(count, labelList.Count);

            foreach (Label label in labelList)
            {
                Assert.AreNotEqual(new string('0', 24), label.Id);
            }


            //Update Batch
            var counter = 1;

            foreach (var label in labelList)
            {
                label.LabelName = "Label1" + counter;
                counter++;
            }

            _labelRepo.Update(labelList);

            counter = 1;
            foreach (var label in labelList)
            {
                Assert.AreEqual(label.LabelName, "Label1" + counter);
                counter++;
            }

            //Delete by criteria
            _labelRepo.Delete(a => a.Text.StartsWith("text1"));

            var countAfterDel = _labelRepo.Count();

            Assert.AreEqual(countAfterDel, 2);
        }
        public void BatchTest()
        {
            var messageList = new List <Message>(new Message[] {
                new Message()
                {
                    FullName = "FullName1", Text = "text1"
                },
                new Message()
                {
                    FullName = "FullName2", Text = "text2"
                },
                new Message()
                {
                    FullName = "FullName3", Text = "text1"
                },
                new Message()
                {
                    FullName = "FullName4", Text = "text2"
                },
                new Message()
                {
                    FullName = "FullName5", Text = "text1"
                },
            });

            //Insert Batch
            _messageRepo.Add(messageList);

            var count = _messageRepo.Count();

            Assert.AreEqual(count, messageList.Count);

            foreach (Message message in messageList)
            {
                Assert.AreNotEqual(new string('0', 24), message.Id);
            }


            //Update Batch
            var counter = 1;

            foreach (var message in messageList)
            {
                message.FullName = "FullName" + counter;
                counter++;
            }

            _messageRepo.Update(messageList);

            counter = 1;
            foreach (var message in messageList)
            {
                Assert.AreEqual(message.FullName, "FullName" + counter);
                counter++;
            }

            //Delete by criteria
            _messageRepo.Delete(a => a.Text.StartsWith("text1"));

            var countAfterDel = _messageRepo.Count();

            Assert.AreEqual(countAfterDel, 2);
        }
示例#10
0
        public StoreProductViewModel GetStoreProducts(int storeId, int pageIndex, int itemsPage, string brandName = "All", string categoryName = "All", string searchText = "")
        {
            _logger.LogInformation("GetStoreProducts called.");

            if (String.IsNullOrEmpty(brandName))
            {
                brandName = "All";
            }

            if (String.IsNullOrEmpty(categoryName))
            {
                categoryName = "All";
            }

            if (String.IsNullOrEmpty(searchText))
            {
                searchText = "";
            }

            // var filterSpecification = new ProductFilterSpecification(string.Empty);
            // var filterPaginatedSpecification =
            //      new ProductFilterPaginatedSpecification(itemsPage * pageIndex, itemsPage, string.Empty);


            //var itemsOnPage = _productRepository.FilterBy(p => p.StoreId == storeId);


            //var filterSpecification = new CatalogFilterSpecification(brandId, typeId);
            //var filterPaginatedSpecification =
            //    new CatalogFilterPaginatedSpecification(itemsPage * pageIndex, itemsPage, brandId, typeId);

            // the implementation below using ForEach and Count. We need a List.
            //var itemsOnPage = _productRepository.Find(filterPaginatedSpecification);
            var totalItems = _productRepository.Count(
                x => x.StoreId == storeId & (x.Brand == brandName || brandName == "All")
                &
                (x.Category == categoryName || categoryName == "All")
                &
                (x.Name.ToLower().Contains(searchText.ToLower()) || searchText == "")
                );

            //var test = _productRepository.Find(x => x.StoreId == storeId,1,2);

            //var test1 = _productRepository.Find(x => x.StoreId == storeId, 2, 2);

            //var command1 = new BsonDocument { { "StoreId", storeId } };
            //var command2 = new BsonDocument { { "Brand", brandName } };

            //var filterBuilder = Builders<BsonDocument>.Filter;
            //var filter = filterBuilder.Eq("StoreId", storeId)
            //& filterBuilder.Eq("Brand", brandName);


            var itemsOnPage = _productRepository.Find(
                x => x.StoreId == storeId & (x.Brand == brandName || brandName == "All")
                &
                (x.Category == categoryName || categoryName == "All")
                &
                (x.Name.ToLower().Contains(searchText.ToLower()) || searchText == "")
                , pageIndex, itemsPage);
            //var itemsOnPage = _productRepository.Find(filterBuilder, pageIndex, itemsPage);

            var brands = _brandRepository.FilterBy(x => x.StoreId == storeId);

            //var brandsList = brands.Select(i => new SelectListItem()
            //{
            //Text = i.Name,
            //Value = i.Name //i.SecondaryId.ToString()
            //});

            //brandsList.Add(new SelectListItem() { Text = "All", Value = "All" });

            //brandsList.OfType<object>().Concat(second);

            //var x = brandsList.ToList();

            var categories = _categoryRepository.FilterBy(x => x.StoreId == storeId);

            var vm = new StoreProductViewModel()
            {
                StoreId               = storeId,
                BrandFilterApplied    = brandName ?? "All",
                CategoryFilterApplied = categoryName ?? "All",
                SearchText            = searchText ?? "",
                StoreProducts         = itemsOnPage.Select(i => new StoreProductItemViewModel()
                {
                    Id          = i.Id.ToString(),
                    SecondaryId = i.SecondaryId,
                    StoreId     = i.StoreId,
                    ProductId   = i.ProductId,
                    Name        = i.Name,
                    PictureUri  = _uriComposer.ComposePicUri(i.PictureUri),
                    Description = i.Description,
                    Price       = i.Price,
                    Amount      = i.Amount,
                    IsMedical   = i.IsMedical,
                    OptionId    = i.OptionId,
                    PercentCbd  = i.PercentCbd,
                    PercentThc  = i.PercentThc,
                    Slung       = i.Slung,
                    StrainType  = i.StrainType,
                    Brand       = i.Brand,
                    Category    = i.Category,
                }),
                PaginationInfo = new PaginationInfoViewModel()
                {
                    StoreId      = storeId,
                    ActualPage   = pageIndex,
                    ItemsPerPage = itemsOnPage.Count(),
                    TotalItems   = totalItems,
                    TotalPages   = int.Parse(Math.Ceiling(((decimal)totalItems / itemsPage)).ToString())
                },
                Brands     = GetBrands(storeId),
                Categories = GetCategories(storeId)
            };

            //vm.PaginationInfo.Next = (vm.PaginationInfo.ActualPage == vm.PaginationInfo.TotalPages - 1) ? "is-disabled" : "";
            //vm.PaginationInfo.Previous = (vm.PaginationInfo.ActualPage == 0) ? "is-disabled" : "";

            return(vm);
        }
        public void BatchTest()
        {
            var language = new Language()
            {
                Abbreviation = "language abbreviation",
                Name         = "language name",
                EnName       = "language en name",
                FlagImage    = "flag image link",
                Locale       = "en"
            };

            _languageRepo.Add(language);

            var announcementList = new List <Announcement>(new Announcement[] {
                new Announcement()
                {
                    Name = "Announcement1", Text = "group1", LanguageId = language.Id
                },
                new Announcement()
                {
                    Name = "Announcement2", Text = "group2", LanguageId = language.Id
                },
                new Announcement()
                {
                    Name = "Announcement3", Text = "group1", LanguageId = language.Id
                },
                new Announcement()
                {
                    Name = "Announcement4", Text = "group2", LanguageId = language.Id
                },
                new Announcement()
                {
                    Name = "Announcement5", Text = "group1", LanguageId = language.Id
                },
            });

            //Insert Batch
            _announcementRepo.Add(announcementList);

            var count = _announcementRepo.Count();

            Assert.AreEqual(count, announcementList.Count);

            foreach (Announcement announcement in announcementList)
            {
                Assert.AreNotEqual(new string('0', 24), announcement.Id);
            }


            //Update Batch
            foreach (var announcement in announcementList)
            {
                announcement.IsActive = false;
            }

            _announcementRepo.Update(announcementList);

            foreach (var announcement in announcementList)
            {
                Assert.AreEqual(announcement.IsActive, false);
            }

            //Delete by criteria
            _announcementRepo.Delete(a => a.Text.StartsWith("group1"));

            var countAfterDel = _announcementRepo.Count();

            Assert.AreEqual(countAfterDel, 2);
        }