示例#1
0
        public async void NewArticleAdded()
        {
            if (CountryName != null && PurchaserUsername != null)
            {
                Country country = await CountryService.GetCountryWithName(CountryName);

                Profile profile = await ProfileService.GetProfileByUsernameAndpassword(PurchaserUsername, "1234");

                Purchaser purchaser = await PurchaserService.GetPurchaserForProfile(profile.Id);

                Article Article = new Article()
                {
                    PurchaserId                = purchaser.Id,
                    SupplierId                 = Id,
                    CountryId                  = country.Id,
                    VailedForCustomer          = ValidForCustomer,
                    DateCreated                = DateTime.Now,
                    ArticleState               = (int)ArticleState.Created,
                    ArticleInformation         = new ArticleInformation(),
                    InternalArticleInformation = new InternalArticleInformation()
                };

                Article.ArticleInformation.CompanyName           = Supplier.CompanyName;
                Article.ArticleInformation.CompanyLocation       = Supplier.CompanyLocation;
                Article.ArticleInformation.FreightResponsibility = Supplier.FreightResponsibility;
                Article.ArticleInformation.PalletExchange        = Supplier.PalletExchange;
                Article.ArticleInformation.Email = Supplier.Profile.Username;

                Article newArticle = await ArticleService.CreateArticle(Article);

                NavigationManager.NavigateTo($"/supplier_info_form/{newArticle.ArticleInformation.Id}", true);
            }
        }
示例#2
0
        public async void DeleteProfile()
        {
            int       profileId = Profiles[0].Id;
            Purchaser purchaser = await PurchaserService.GetPurchaserForProfile(profileId);

            await PurchaserService.DeletePurchaserForProfile(ProfileClicked);

            NavigationManager.NavigateTo($"/user_view/{purchaser.CountryId}", true);
        }
示例#3
0
        public async Task GetPurchaserForProfileReturnsNewPurchaserIfNotExist()
        {
            // arrange
            PurchaserService purchaserService = new PurchaserService(_client);
            Purchaser        expected         = new Purchaser();

            // act
            Purchaser actual = await purchaserService.GetPurchaserForProfile(0);

            // assert
            Assert.IsTrue(expected.Country == actual.Country);
            Assert.IsTrue(expected.Id == actual.Id);
            CollectionAssert.AreEquivalent(expected.Articles, actual.Articles);
            Assert.IsTrue(expected.CountryId == actual.CountryId);
            Assert.IsTrue(expected.Id == actual.Id);
            Assert.IsTrue(expected.ProfileId == actual.ProfileId);
        }
示例#4
0
        public async Task GetPurchaserForProfileReturnsExistingPurchaser()
        {
            // arrange
            PurchaserService purchaserService = new PurchaserService(_client);
            Purchaser        purchaser        = new Purchaser()
            {
                Id        = 0,
                ProfileId = 0,
                CountryId = 0,
                Profile   = new Profile()
                {
                    Id       = 0,
                    Username = "******",
                    Password = "******",
                    Usertype = 2
                }
            };

            Purchaser expected = await purchaserService.CreatePurchaser(purchaser);

            // act
            Purchaser actual = await purchaserService.GetPurchaserForProfile(expected.ProfileId);

            List <Purchaser> list = await purchaserService.GetPurchasers();

            // assert
            Assert.IsTrue(expected.Country == actual.Country);
            Assert.IsTrue(expected.Id == actual.Id);
            CollectionAssert.AreEquivalent(expected.Articles, actual.Articles);
            Assert.IsTrue(expected.CountryId == actual.CountryId);
            Assert.IsTrue(expected.Id == actual.Id);
            Assert.IsTrue(expected.Profile.Id == actual.Profile.Id);
            Assert.IsTrue(expected.Profile.Password == actual.Profile.Password);
            CollectionAssert.AreEquivalent(expected.Profile.Purchasers, actual.Profile.Purchasers);
            Assert.IsTrue(expected.Profile.Username == actual.Profile.Username);
            CollectionAssert.AreEquivalent(expected.Profile.Purchasers, actual.Profile.Purchasers);
            Assert.IsTrue(expected.Profile.Usertype == actual.Profile.Usertype);
            CollectionAssert.AreEquivalent(expected.Profile.Countries, actual.Profile.Countries);
            Assert.IsTrue(list.Count == 1);


            await purchaserService.DeletePurchaserForProfile(expected.ProfileId);
        }