public void GetExportSuppliers_WhenCalled_ReturnExportSuppliers()
        {
            var storageCard = new StorageCard {
                Name = "storageCard"
            };
            var supplier1 = new Supplier {
                Name = "supplier1"
            };
            var supplier2 = new Supplier {
                Name = "supplier2"
            };
            var storageCardSuppliers = new List <StorageCardSupplier>
            {
                new StorageCardSupplier
                {
                    StorageCard = storageCard,
                    Supplier    = supplier2,
                },
                new StorageCardSupplier
                {
                    StorageCard = storageCard,
                    Supplier    = supplier1,
                },
            };

            var result = ExportHelper.GetExportSuppliers(storageCardSuppliers);

            Assert.That(result.Count, Is.EqualTo(2));
            Assert.That(result[0].StorageCardName, Is.EqualTo(storageCard.Name));
            Assert.That(result[0].SupplierName, Is.EqualTo(supplier1.Name));
            Assert.That(result[1].StorageCardName, Is.EqualTo(storageCard.Name));
            Assert.That(result[1].SupplierName, Is.EqualTo(supplier2.Name));
        }
Beispiel #2
0
 public void Init()
 {
     for (int i = 0; i < CardDatabase.Instance().GetCardCount(); i++)
     {
         GameObject  card = Instantiate(m_card) as GameObject;
         StorageCard s    = card.GetComponent <StorageCard>();
         s.SetData(CardDatabase.Instance().GetCardData(i));
     }
     SoundManager.Instance.PlayBGM(2);
 }
Beispiel #3
0
        public void DeleteStorageCard(StorageCard storageCard)
        {
            var storageCardSuppliers = this.databaseContext.StorageCardSuppliers.Where(s => s.StorageCard == storageCard);

            this.databaseContext.StorageCardSuppliers.RemoveRange(storageCardSuppliers);

            var items = this.databaseContext.Items.Where(i => i.StorageCard == storageCard);

            this.databaseContext.Items.RemoveRange(items);

            this.databaseContext.StorageCards.Remove(storageCard);
        }
        public SuppliersViewModel(StorageCard selectedStorageCard)
        {
            if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
            {
                return;
            }

            this.SelectedStorageCard = selectedStorageCard;

            this.AssignSupplierCommand   = new(this);
            this.UnassignSupplierCommand = new(this);

            this.LoadSuppliersAsync();
        }
Beispiel #5
0
        public void GetStorageCardSupplier_IsInArgument_ReturnStorageCardSupplier()
        {
            var storageCard = new StorageCard {
                Name = "storageCard"
            };
            var supplier = new Supplier {
                Name = "supplier"
            };
            var storageCardSuppliers = new List <StorageCardSupplier>
            {
                new StorageCardSupplier
                {
                    StorageCard = storageCard,
                    Supplier    = supplier,
                },
            };

            var databaseHelper = new DatabaseHelper(this.context);
            var result         = databaseHelper.GetStorageCardSupplier(storageCard, supplier, storageCardSuppliers);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.StorageCard, Is.EqualTo(storageCard));
            Assert.That(result.Supplier, Is.EqualTo(supplier));
        }
        public void GetExportItems_WhenCalled_ReturnExportItems()
        {
            var account = new Account {
                Name = "account"
            };
            var category = new Category {
                Name = "category"
            };
            var store = new Store {
                Name = "store"
            };
            var item1 = new Item
            {
                DateTime = DateTime.Now,
                Name     = "item1",
                Movement = 1,
                Qty      = 5,
                Price    = 10,
                Invoice  = "invoice1",
                Customer = null,
            };
            var item2 = new Item
            {
                DateTime = DateTime.Now,
                Name     = "item2",
                Movement = -1,
                Qty      = 10,
                Price    = 5,
                Invoice  = "invoice2",
                Customer = new Customer {
                    Name = "customer"
                },
            };
            var storageCard = new StorageCard
            {
                Account  = account,
                Category = category,
                Store    = store,
            };

            storageCard.Items.Add(item2);
            storageCard.Items.Add(item1);
            var storageCards = new List <StorageCard> {
                storageCard
            };

            var result = ExportHelper.GetExportItems(storageCards);

            Assert.That(result.Count, Is.EqualTo(2));
            Assert.That(result[0].StorageCardName, Is.EqualTo(storageCard.Name));
            Assert.That(result[0].AccountName, Is.EqualTo(account.Name));
            Assert.That(result[0].CategoryName, Is.EqualTo(category.Name));
            Assert.That(result[0].StoreName, Is.EqualTo(store.Name));
            Assert.That(result[0].ItemDateTime, Is.EqualTo(item1.DateTime));
            Assert.That(result[0].ItemName, Is.EqualTo(item1.Name));
            Assert.That(result[0].ItemMovement, Is.EqualTo(item1.Movement));
            Assert.That(result[0].ItemQty, Is.EqualTo(item1.Qty));
            Assert.That(result[0].ItemPrice, Is.EqualTo(item1.Price));
            Assert.That(result[0].ItemInvoice, Is.EqualTo(item1.Invoice));
            Assert.That(result[0].ItemCustomerName, Is.EqualTo(item1.Customer?.Name));
            Assert.That(result[1].StorageCardName, Is.EqualTo(storageCard.Name));
            Assert.That(result[1].AccountName, Is.EqualTo(account.Name));
            Assert.That(result[1].CategoryName, Is.EqualTo(category.Name));
            Assert.That(result[1].StoreName, Is.EqualTo(store.Name));
            Assert.That(result[1].ItemDateTime, Is.EqualTo(item2.DateTime));
            Assert.That(result[1].ItemName, Is.EqualTo(item2.Name));
            Assert.That(result[1].ItemMovement, Is.EqualTo(item2.Movement));
            Assert.That(result[1].ItemQty, Is.EqualTo(item2.Qty));
            Assert.That(result[1].ItemPrice, Is.EqualTo(item2.Price));
            Assert.That(result[1].ItemInvoice, Is.EqualTo(item2.Invoice));
            Assert.That(result[1].ItemCustomerName, Is.EqualTo(item2.Customer?.Name));
        }
Beispiel #7
0
        private void AddTestData()
        {
            var account1 = new Account {
                DateTime = this.dateTime, Name = "account1"
            };
            var account2 = new Account {
                DateTime = this.dateTime, Name = "account2"
            };
            var account3 = new Account {
                DateTime = this.dateTime, Name = "account3"
            };

            var category1 = new Category {
                DateTime = this.dateTime, Name = "category1"
            };
            var category2 = new Category {
                DateTime = this.dateTime, Name = "category2"
            };
            var category3 = new Category {
                DateTime = this.dateTime, Name = "category3"
            };

            var customer1 = new Customer {
                DateTime = this.dateTime, Name = "customer1"
            };
            var customer2 = new Customer {
                DateTime = this.dateTime, Name = "customer2"
            };
            var customer3 = new Customer {
                DateTime = this.dateTime, Name = "customer3"
            };

            var store1 = new Store {
                DateTime = this.dateTime, Name = "store1"
            };
            var store2 = new Store {
                DateTime = this.dateTime, Name = "store2"
            };
            var store3 = new Store {
                DateTime = this.dateTime, Name = "store3"
            };

            var supplier1 = new Supplier {
                DateTime = this.dateTime, Name = "supplier1"
            };
            var supplier2 = new Supplier {
                DateTime = this.dateTime, Name = "supplier2"
            };
            var supplier3 = new Supplier {
                DateTime = this.dateTime, Name = "supplier3"
            };

            var storageCard1 = new StorageCard
            {
                DateTime = this.dateTime,
                Name     = "storageCard1",
                Account  = account1,
                Category = category1,
                Store    = store1,
            };

            var storageCard2 = new StorageCard
            {
                DateTime = this.dateTime,
                Name     = "storageCard2",
                Account  = account2,
                Category = category2,
                Store    = store2,
            };

            var storageCard3 = new StorageCard
            {
                DateTime = this.dateTime,
                Name     = "storageCard3",
                Account  = account3,
                Category = category3,
                Store    = store3,
            };

            var storageCardSupplier1 = new StorageCardSupplier
            {
                DateTime    = this.dateTime,
                StorageCard = storageCard1,
                Supplier    = supplier1,
            };

            var storageCardSupplier2 = new StorageCardSupplier
            {
                DateTime    = this.dateTime,
                StorageCard = storageCard2,
                Supplier    = supplier1,
            };

            var storageCardSupplier3 = new StorageCardSupplier
            {
                DateTime    = this.dateTime,
                StorageCard = storageCard2,
                Supplier    = supplier2,
            };

            var storageCardSupplier4 = new StorageCardSupplier
            {
                DateTime    = this.dateTime,
                StorageCard = storageCard3,
                Supplier    = supplier1,
            };

            var storageCardSupplier5 = new StorageCardSupplier
            {
                DateTime    = this.dateTime,
                StorageCard = storageCard3,
                Supplier    = supplier2,
            };

            var storageCardSupplier6 = new StorageCardSupplier
            {
                DateTime    = this.dateTime,
                StorageCard = storageCard3,
                Supplier    = supplier3,
            };

            var item1 = new Item
            {
                DateTime    = this.dateTime,
                Name        = "item1",
                Movement    = 1,
                Qty         = 1,
                Price       = 1,
                Invoice     = "invoice1",
                StorageCard = storageCard1,
                Customer    = customer1,
            };

            this.context.AddRange(
                account1,
                account2,
                account3,
                category1,
                category2,
                category3,
                customer1,
                customer2,
                customer3,
                store1,
                store2,
                store3,
                supplier1,
                supplier2,
                supplier3,
                storageCard1,
                storageCard2,
                storageCard3,
                storageCardSupplier1,
                storageCardSupplier2,
                storageCardSupplier3,
                storageCardSupplier4,
                storageCardSupplier5,
                storageCardSupplier6,
                item1);

            this.context.SaveChanges();
        }
Beispiel #8
0
 public List <StorageCardSupplier> GetStorageCardSuppliers(StorageCard storageCard)
 {
     return(this.databaseContext.StorageCardSuppliers.Include(s => s.Supplier).Where(s => s.StorageCard == storageCard).ToList());
 }
Beispiel #9
0
 public StorageCardSupplier GetStorageCardSupplier(StorageCard storageCard, Supplier supplier, List <StorageCardSupplier> addedStorageCardSuppliers = null)
 {
     return(addedStorageCardSuppliers?.Where(s => s.StorageCard == storageCard && s.Supplier == supplier).SingleOrDefault()
            ?? this.databaseContext.StorageCardSuppliers.Where(s => s.StorageCard == storageCard && s.Supplier == supplier).SingleOrDefault());
 }