public void Add_Buyer_To_BuyerList_When_Received_From_BuyerVM()
        {
            //Arrange
            _paymentViewModel = new PaymentViewModel(_contextMock.Object, _messageBoxMock.Object, _navigationServiceMock.Object);

            int actulNumberOfBuyers = _paymentViewModel.BuyerList.Count;

            var buyerToAdd = new Buyer
            {
                ID = 1,
                FirstName = "Michał",
                LastName = "Rakel",
                REGON = "4234242",
                NIP = "3234326576",
                CompanyName = "firma",
                Address = new Address
                {
                    City = "Kraków",
                    StreetAddress = "ul. Kredki 5/8a",
                    ZipCode = "31-063"
                }
            };

            //Act
            Messenger.Default.Send(new MessageService(buyerToAdd, EntityState.Added), MessengerToken.PaymentVm);

            //Verify
            Assert.IsTrue(_paymentViewModel.BuyerList.Count==actulNumberOfBuyers+1);
        }
Exemple #2
0
        public BuyerViewModel(IUnitOfWork context, IFrameNavigationService navigationService)
            : base(context,navigationService)
        {
            OriginalModel = new Buyer();

            HandleNavigationParameter(navigationService.Parameter);

            ConfigureValidationRules();
        }
Exemple #3
0
        private void AddBuyer(Buyer buyer)
        {
            try
            {
                Context.People.Add(buyer);
                SelectedSeller.Buyers.Add(buyer);
                Context.Complete();

            }
            catch (Exception)
            {
                throw new Exception("Nie udało się stworzyć nabywcy");
            }
            var message = new MessageService(buyer, EntityState.Added);
            Messenger.Default.Send(message, MessengerToken.BuyerListVm);
            Messenger.Default.Send(message, MessengerToken.PaymentVm);
            StatusSetter.SetStatus("Nabywca dodany");
            GoBack();
        }
Exemple #4
0
        public void Returns_True_When_Buyers_Are_Equal()
        {
            var aBuyer = new Buyer
            {
                ID = 1,
                FirstName = "Krzysztof",
                LastName = "Braik",
                CompanyName = "Ven",
                NIP = "562504040",
                REGON = "2342",
                Address = new Address
                {
                    City = "Warszawa",
                    StreetAddress = "Tor wyścigowy 54",
                    ZipCode = "42-232"
                }
            };

            var bBuyer = new Buyer
            {
                ID = 1,
                FirstName = "Krzysztof",
                LastName = "Braik",
                CompanyName = "Ven",
                NIP = "562504040",
                REGON = "2342",
                Address = new Address
                {
                    City = "Warszawa",
                    StreetAddress = "Tor wyścigowy 54",
                    ZipCode = "42-232"
                }
            };

            Assert.IsTrue(aBuyer.Equals(bBuyer));
        }
Exemple #5
0
 protected override void ReadFromModel(Person person)
 {
     base.ReadFromModel(person);
     OriginalModel = person as Buyer;
 }
Exemple #6
0
 private void EditBuyer(Buyer buyer)
 {
     try
     {
         Context.Complete();
     }
     catch
     {
         throw new Exception("Nie udało się zmodyfikować nabywcy");
     }
     Messenger.Default.Send(new MessageService(buyer, EntityState.Edited), MessengerToken.BuyerListVm);
     StatusSetter.SetStatus("Nabywca zmodyfikowany");
     GoBack();
 }
        public override void TestInitialize()
        {
            base.TestInitialize();
            using (var bc = new UnitOfWork())
            {
                var newSeller = new Seller
                {
                    FirstName = "Michał",
                    LastName = "Rakel",
                    BankName = "mBank",
                    BankAccountNumber = "32 3245 5456 5435 3242 5456 1296",
                    NIP = "3234326576",
                    Address = new Address
                    {
                        City = "Kraków",
                        StreetAddress = "ul. Kredki 5/8a",
                        ZipCode = "31-063"
                    }
                };

                bc.People.Add(newSeller);

                var newBuyer = new Buyer
                {
                    FirstName = "Michał",
                    LastName = "Braik",
                    CompanyName = "Ven",
                    NIP = "562504040",
                    Address = new Address
                    {
                        City = "Warszawa",
                        StreetAddress = "Tor wyścigowy 54",
                        ZipCode = "42-232"
                    }
                };

                newSeller.Buyers.Add(newBuyer);
                bc.Complete();
            }
        }
Exemple #8
0
 private bool Equals(Buyer other)
 {
     return base.Equals(other);
 }
Exemple #9
0
 public MessageService(Buyer buyer, EntityState entityState)
 {
     Buyer = buyer;
     EntityState = entityState;
 }
        public void BuyersAssignedToSeller_Gets_List_Of_Buyers_For_Seller()
        {
            //Arrange
            int sellerId;
            using (var bc = new UnitOfWork())
            {
                var seller = new Seller
                {
                    FirstName = "Michał",
                    LastName = "Rakel",
                    BankName = "mBank",
                    BankAccountNumber = "32 3245 5456 5435 3242 5456 1296",
                    NIP = "3234326576",
                    Address = new Address
                    {
                        City = "Kraków",
                        StreetAddress = "ul. Kredki 5/8a",
                        ZipCode = "31-063"
                    }
                };

                var buyer1 = new Buyer
                {
                    FirstName = "Paweł",
                    LastName = "Rakel",
                    NIP = "3234326576",
                    Address = new Address
                    {
                        City = "Kraków",
                        StreetAddress = "ul. Kredki 5/8a",
                        ZipCode = "31-063"
                    }
                };

                var buyer2 = new Buyer
                {
                    FirstName = "Piotrek",
                    LastName = "Rakel",
                    NIP = "3234326576",
                    Address = new Address
                    {
                        City = "Kraków",
                        StreetAddress = "ul. Kredki 5/8a",
                        ZipCode = "31-063"
                    }
                };

                bc.People.Add(seller);
                seller.Buyers.Add(buyer1);
                seller.Buyers.Add(buyer2);
                bc.Complete();
                sellerId = seller.ID;
            }

            using (var bc = new UnitOfWork())
            {
                //Act
                var buyerList = bc.People.FindBuyers(b => b.Seller.ID == sellerId);

                //Verify
                Assert.IsTrue(buyerList.Count()==2);

            }
        }
        private Invoice CreateInvoice()
        {
            var buyer = new Buyer
            {
                ID = 2,
                FirstName = "Tomasz",
                LastName = "Pakul",
                CompanyName = "Tymbol",
                NIP = "5455914065",
                Address = new Address
                {
                    City = "Kraków",
                    StreetAddress = "ul. Kolorowe 3",
                    ZipCode = "30-710"
                }
            };

            _selectedSeller = new Seller
            {
                ID = 1,
                FirstName = "Michał",
                LastName = "Rakel",
                BankName = "mBank",
                BankAccountNumber = "32 3245 5456 5435 3242 5456 1296 ",
                NIP = "3234326576",
                Address = new Address
                {
                    City = "Kraków",
                    StreetAddress = "ul. Kredki 5/8a",
                    ZipCode = "31-063"
                }
            };
            var myInvoice = new Invoice
            {
                ID = 1,
                IssueDate = new DateTime(2015, 5, 6),
                Number = "3/2015",
                PaymentMethod = PaymentMethod.Transfer,
                SaleDate = new DateTime(2015, 5, 6),
                PaymentDetails = new List<PaymentDetail>
                         {
                            new PaymentDetail
                            {
                                Description = "Czynsz za lokal ul. Marsa 3 maj",
                                MeasureUnit = "szt.",
                                PricePerUnit = 5300,
                                Quantity = 1
                            },
                            new PaymentDetail
                            {
                                Description = "Czynsz za lokal ul. wris 3 lipiec",
                                MeasureUnit = "szt.",
                                PricePerUnit = 3500,
                                Quantity = 1
                            }

                         },

                Buyer = buyer,
                Seller = _selectedSeller,
            };

            return myInvoice;
        }