Ejemplo n.º 1
0
 public void refresh()
 {
     using (var db = new MarketDbContext())
     {
         DailyCosts = db.DailyCosts.ToList();
     }
 }
Ejemplo n.º 2
0
        public void OrderManager_Payment_Guest_ShouldPass()
        {
            using var context = new MarketDbContext(inMemoryConnection);

            string storeName = GetStoreName();
            // setup test
            StoreContactDetails details = new StoreContactDetails(storeName, "*****@*****.**", "location", "222", "222", "bank", "cool store");

            storeHandler.OpenStore(details, Owner, context);
            Store s = storeHandler.Stores(context).Where(s => s.ContactDetails.Name.Equals(storeName, StringComparison.InvariantCultureIgnoreCase)).First();

            string itemName = "testItemD";
            Item   item     = s.AddItem(itemName, 2, new HashSet <string>()
            {
                "CategoryA"
            }, 1.22, context, keyWords: new HashSet <string>()
            {
                "test"
            });

            Dictionary <Guid, StoreCart> shoppingCart = new Dictionary <Guid, StoreCart>();
            StoreCart cart = new StoreCart(s.Id);

            cart.AddToStoreCart(item.Id, 1);
            shoppingCart.Add(s.Id, cart);

            PaymentReal realPayment = new PaymentReal(new System.Net.Http.HttpClient());

            orderManager.Payment.Real = realPayment;
            Order order = null;

            Assert.DoesNotThrow(() => order = orderManager.DiscountAndReserve(GetGuestId(), shoppingCart, context));
            Assert.IsNotNull(order);
            Assert.DoesNotThrow(() => orderManager.CollectPayment(order.userKey, order.OrderId, "1111222233334444", "12/2021", "111", "name", "222333231", context));
        }
        //update button: select current products and change any information
        private void btn_update_Click(object sender, EventArgs e)
        {
            try
            {
                if (_Id != -1)
                {
                    using (MarketDbContext marketDbContext = new MarketDbContext())
                    {
                        Model.TopSellingStation _TopSellingStation = marketDbContext.TopSellingStations.Where(x => x.Id == _Id).FirstOrDefault();

                        _TopSellingStation.Name        = txt_Name.Text;
                        _TopSellingStation.Category    = txt_Category.Text;
                        _TopSellingStation.Price       = Convert.ToDecimal(txt_Price.Text == "" ? null : txt_Price.Text);
                        _TopSellingStation.Count       = Convert.ToInt16(txt_Count.Text == "" ? null : txt_Count.Text);
                        _TopSellingStation.SellingTime = Convert.ToDateTime(date_time.Text);
                        _TopSellingStation.Currency    = (Currency)cmbx_Currency.SelectedIndex;
                        _TopSellingStation.Usage       = Convert.ToBoolean(cmbx_Usage.Text);
                        _TopSellingStation.Weight      = (Weight)cmbx_Weight.SelectedIndex;

                        marketDbContext.SaveChanges();
                        dataGrid_allProduct.DataSource = marketDbContext.TopSellingStations.ToList();
                        _Id = -1;
                    }
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
            finally
            {
                Clear();
                btn_add.Enabled = true;
            }
        }
Ejemplo n.º 4
0
        public void OrderManager_ValidOrder_TooManyItems_ShouldFail()
        {
            using var context = new MarketDbContext(inMemoryConnection);

            string storeName = GetStoreName();

            // setup test
            StoreContactDetails details = new StoreContactDetails(storeName, "*****@*****.**", "location", "222", "222", "bank", "cool store");

            storeHandler.OpenStore(details, Owner, context);
            Store s = storeHandler.Stores(context).Where(s => s.ContactDetails.Name.Equals(storeName, StringComparison.InvariantCultureIgnoreCase)).First();

            string itemName = "testItemC";
            Item   item     = s.AddItem(itemName, 1, new HashSet <string>()
            {
                "CategoryA"
            }, 1.22, context);

            Dictionary <Guid, StoreCart> shoppingCart = new Dictionary <Guid, StoreCart>();
            StoreCart cart = new StoreCart(s.Id);

            cart.AddToStoreCart(item.Id, 3);
            shoppingCart.Add(s.Id, cart);

            // test
            Assert.Throws <ItemAmountException>(() => orderManager.DiscountAndReserve(Buyer1, shoppingCart, context));
        }
Ejemplo n.º 5
0
        public void OrderManager_InvalidOrder_Guest_ShouldPass()
        {
            using var context = new MarketDbContext(inMemoryConnection);

            string storeName = GetStoreName();
            // setup test
            StoreContactDetails details = new StoreContactDetails(storeName, "*****@*****.**", "location", "222", "222", "bank", "cool store");

            Store s = storeHandler.OpenStore(details, Owner, context);

            string itemName = "testItemD";
            Item   item     = s.AddItem(itemName, 2, new HashSet <string>()
            {
                "CategoryA"
            }, 1.22, context);

            Dictionary <Guid, StoreCart> shoppingCart = new Dictionary <Guid, StoreCart>();
            StoreCart cart = new StoreCart(s.Id);

            cart.AddToStoreCart(item.Id, 1);
            shoppingCart.Add(s.Id, cart);

            Order order = null;

            Assert.DoesNotThrow(() => order = orderManager.DiscountAndReserve(GetGuestId(), shoppingCart, context));
            Assert.IsNotNull(order);
            order.Status = OrderStatus.DELIVERED;
            orderManager.LogOrder(order.userKey, order.OrderId, context);
            Assert.AreEqual(orderManager.GetStoreOrdersHistory(s.Id, context).Count, 1);
        }
Ejemplo n.º 6
0
        public void RemovePermission_Owner_ShouldPass()
        {
            using var context = new MarketDbContext(inMemoryConnection);

            AddPermission_Owner_ShouldPass();
            Assert.DoesNotThrow(() => storeManagement.RemovePermission(storeID, TEST_MANAGER, TEST_OWNER, Permission.HISTORY, context));
        }
Ejemplo n.º 7
0
        public void RemoveManager_NoPermission_ShouldFail()
        {
            using var context = new MarketDbContext(inMemoryConnection);

            AppointManager_Owner_ShouldPass();
            Assert.Throws <PermissionException>(() => storeManagement.RemoveManager(storeID, TEST_NEW_USER, TEST_MANAGER, context));
        }
Ejemplo n.º 8
0
        public void SearchItems_ByKeyWords_ShouldPass()
        {
            using var context = new MarketDbContext(inMemoryConnection);
            Store[] stores = DataForTests.CreateStoresForSearchTests(storeHandler, context);

            Dictionary <Guid, ReadOnlyCollection <Item> > results =
                searchFacade.SearchItems(context: context,
                                         filterItemRank: null,
                                         filterMinPrice: null,
                                         filterMaxPrice: null,
                                         filterStoreRank: null,
                                         keywords: new List <string>()
            {
                "word50"
            });

            Assert.AreEqual(2, results.Keys.Count);

            ReadOnlyCollection <Item> resultStore1 = results[stores[1].Id];
            ReadOnlyCollection <Item> resultStore3 = results[stores[3].Id];

            Assert.AreEqual("item five", resultStore1[0].Name);
            Assert.AreEqual("item twenty", resultStore3[0].Name);

            Assert.AreEqual(1, resultStore1.Count);
            Assert.AreEqual(1, resultStore3.Count);
        }
Ejemplo n.º 9
0
        public void SearchItems_ByNameAndCategoryAndKeyWords_FilterByPrice_SpellMistake_ShouldPass()
        {
            using var context = new MarketDbContext(inMemoryConnection);
            Store[] stores = DataForTests.CreateStoresForSearchTests(storeHandler, context);

            Dictionary <Guid, ReadOnlyCollection <Item> > results =
                searchFacade.SearchItems(context: context,
                                         filterItemRank: null,
                                         filterMinPrice: null,
                                         filterMaxPrice: 20.4,
                                         filterStoreRank: null,
                                         name: "itam one",
                                         category: "cat1",
                                         keywords: new List <string>()
            {
                "word1"
            });

            Assert.AreEqual(2, results.Keys.Count);

            ReadOnlyCollection <Item> resultStore  = results[stores[0].Id];
            ReadOnlyCollection <Item> resultStore1 = results[stores[1].Id];

            Assert.AreEqual("item one", resultStore[0].Name);
            Assert.AreEqual("item one", resultStore1[0].Name);

            Assert.AreEqual(1, resultStore.Count);
            Assert.AreEqual(1, resultStore1.Count);
        }
Ejemplo n.º 10
0
        private void button13_Click_1(object sender, EventArgs e)
        {
            string          musteriadi = " ";
            string          soyadi     = " ";
            MarketDbContext db         = new MarketDbContext();

            foreach (var deger in db.Musteris)
            {
                if (deger.MusteriID == Convert.ToInt32(textBox3.Text))
                {
                    musteriadi = deger.MusteriAd;
                    soyadi     = deger.MusteriSoyad;
                }
            }
            var cntxtt = new MarketDbContext();

            _ = cntxtt.Borcs.Add(new Moduls.Entity.Borc
            {
                MusteriAd    = musteriadi,
                MusteriSoyad = soyadi,
                MusteriID    = Convert.ToInt32(textBox3.Text),
                Tutar        = Convert.ToInt32(textBox2.Text)
            });

            var cevap = cntxtt.SaveChanges();

            if (cevap <= 0)
            {
                MessageBox.Show("Satın Alma İşlemi Tamamlanamamıştır");
            }
            else
            {
                MessageBox.Show("Satın Alma İşlemi Tamamlanmıştır");
            }
        }
Ejemplo n.º 11
0
        public void Setup()
        {
            inMemoryConnection = DbConnectionFactory.CreateTransient();
            using var context  = new MarketDbContext(inMemoryConnection);
            context.Init();

            filterStoreRank  = new FilterByStoreRank(4);
            filterByItemRank = new FilterByItemRank(3);
            filterByPrice    = new FilterByPrice(5, 20.66);

            RegisteredUser owner = new RegisteredUser("OWNER", new byte[] { });

            context.Users.Add(owner);
            Guid Owner   = owner.ID;
            Guid storeID = Guid.NewGuid();

            store = new Store(storeID, DataForTests.CreateTestContactDetails(), new PurchasePolicy(storeID), new DiscountPolicy(storeID), Owner, context);
            context.Stores.Add(store);
            HashSet <Category> categories = new HashSet <Category>()
            {
                new Category("cat1"), new Category("cat2")
            };

            context.Categories.AddRange(categories);
            item = new Item(Guid.NewGuid(), store.Id, "name ", 2, categories, 3.55);
            context.Items.Add(item);
            context.SaveChanges();
        }
Ejemplo n.º 12
0
        private void CheckInventory(StoreCart storeCart, MarketDbContext context)
        {
            Guid storeID = storeCart.StoreID;
            IStoreInventoryManager store = StoreHandler.GetStoreInventoryManager(storeID, context);

            store.IsOrderItemsAmountAvailable(storeCart.Items, context);
        }
Ejemplo n.º 13
0
 public void notifyEvent(INotificationEvent notificationEvent, MarketDbContext context)
 {
     foreach (NotificationObserver observer in observers)
     {
         observer.NotifyEvent(notificationEvent, context);
     }
 }
Ejemplo n.º 14
0
        internal void CancelPayment(Guid?userID, Guid orderID, string cardNum, MarketDbContext context)
        {
            if (!TryGetOrder(orderID, out Order order, context))
            {
                throw new OrderNotValidException(string.Format("No order Exists with this ID:", orderID));
            }
            if (userID != order.userKey)
            {
                throw new OrderNotValidException(string.Format("order:{0} was not made by user:{1}", orderID, userID));
            }
            if (order.Status != OrderStatus.PAYED_FOR)
            {
                switch (order.Status)
                {
                case OrderStatus.PENDING:
                    throw new OrderNotValidException(string.Format("order:{0} was not payed for", orderID));

                case OrderStatus.DELIVERED:
                    throw new OrderNotValidException(string.Format("order:{0} was already delivered", orderID));

                case OrderStatus.COMPLETED:
                    throw new OrderNotValidException(string.Format("order:{0} was completed", orderID));
                }
            }
            try
            {
                _ = Payment.Cancel(userID, order, cardNum).Result;
                context.Orders.Remove(order);
            }
            catch (Exception e)
            {
                throw new PaymentFailedException(e.Message);
            }
        }
Ejemplo n.º 15
0
        private void button9_Click(object sender, EventArgs e)
        {
            MarketDbContext aa   = new MarketDbContext();
            var             borc = aa.Borcs.ToList();

            dataGridView1.DataSource = borc;
        }
Ejemplo n.º 16
0
        public void SearchItems_ByName_spellMistake_SpellingCannotHelp_ShouldFail()
        {
            using var context = new MarketDbContext(inMemoryConnection);
            Store[] stores = DataForTests.CreateStoresForSearchTests(storeHandler, context);

            IStoreInventoryManager inventoryManager3 = storeHandler.GetStoreInventoryManager(stores[3].Id, context);

            inventoryManager3.AddItem("apple computer", 300, new HashSet <string>()
            {
                "electrical"
            }, 2000, context,
                                      keyWords: new HashSet <string>()
            {
                "computers", "electronic"
            });

            Dictionary <Guid, ReadOnlyCollection <Item> > results =
                searchFacade.SearchItems(context: context,
                                         filterItemRank: null,
                                         filterMinPrice: 11,
                                         filterMaxPrice: 2000,
                                         filterStoreRank: null,
                                         name: "paplee compuetr",
                                         category: "electrical");

            Assert.AreEqual(0, results.Keys.Count);
        }
Ejemplo n.º 17
0
        public void AppointOwner_Owner_ShouldPass()
        {
            using var context = new MarketDbContext(inMemoryConnection);

            Assert.DoesNotThrow(() => storeManagement.AppointOwner(storeID, TEST_NEW_USER, TEST_FIRST_OWNER, STUB_USER_NAME, context));
            //Assert.DoesNotThrow(() => storeManagement.AppointOwner(storeID, TEST_NEW_USER, TEST_FIRST_OWNER, STUB_USER_NAME, context));
        }
Ejemplo n.º 18
0
        public void GetAllStoresInformation_NoStores_ShouldPass()
        {
            using var context = new MarketDbContext(inMemoryConnection);
            ReadOnlyCollection <Store> data = searchFacade.GetAllStoresInformation(context);

            Assert.AreEqual(0, data.Count);
        }
Ejemplo n.º 19
0
        public void RemovePermission_NoCertification_ShouldFail()
        {
            using var context = new MarketDbContext(inMemoryConnection);

            AddPermission_Owner_ShouldPass();
            Assert.Throws <CertificationException>(() => storeManagement.RemovePermission(storeID, TEST_MANAGER, TEST_NEW_USER, Permission.INVENTORY, context));
        }
Ejemplo n.º 20
0
        private void TestAllConditionsAndFilters(string nameToSearch, string nameToFind)
        {
            using var context = new MarketDbContext(inMemoryConnection);
            Store[] stores = DataForTests.CreateStoresForSearchTests(storeHandler, context);

            Dictionary <Guid, ReadOnlyCollection <Item> > results =
                searchFacade.SearchItems(
                    context: context,
                    filterItemRank: 0,
                    filterMinPrice: 20.4,
                    filterMaxPrice: 20.4,
                    filterStoreRank: 0,
                    name: nameToSearch,
                    category: "cat2",
                    keywords: new List <string>()
            {
                "word3"
            });

            Assert.AreEqual(2, results.Keys.Count);

            ReadOnlyCollection <Item> resultStore  = results[stores[0].Id];
            ReadOnlyCollection <Item> resultStore2 = results[stores[2].Id];

            Assert.AreEqual(nameToFind, resultStore[0].Name);
            Assert.AreEqual(nameToFind, resultStore2[0].Name);

            Assert.AreEqual(1, resultStore.Count);
            Assert.AreEqual(1, resultStore2.Count);
        }
Ejemplo n.º 21
0
        public void Setup()
        {
            inMemoryConnection = Effort.DbConnectionFactory.CreateTransient();
            using var context  = new MarketDbContext(inMemoryConnection);
            context.Init();
            RegisteredUser first_owner = new RegisteredUser("FIRST_OWNER", new byte[] { });

            context.Users.Add(first_owner);
            TEST_FIRST_OWNER = first_owner.ID;
            RegisteredUser owner = new RegisteredUser("OWNER", new byte[] { });

            context.Users.Add(owner);
            TEST_OWNER = owner.ID;
            RegisteredUser manager = new RegisteredUser("MANAGER", new byte[] { });

            context.Users.Add(manager);
            TEST_MANAGER = manager.ID;
            RegisteredUser new_user = new RegisteredUser("NEW_USER", new byte[] { });

            context.Users.Add(new_user);
            TEST_NEW_USER   = new_user.ID;
            storeName       = DataForTests.CreateTestContactDetails().Name;
            storeHandler    = new StoreHandler();
            orderManager    = new OrderManager(storeHandler, inMemoryConnection);
            storeManagement = new StoreManagementFacade(storeHandler, orderManager);
            storeHandler.OpenStore(DataForTests.CreateTestContactDetails(), TEST_FIRST_OWNER, context);
            Store store = storeHandler.GetStoreByName(storeName, context);

            store.AddOwner(TEST_OWNER, TEST_FIRST_OWNER, STUB_USER_NAME, storeHandler, context);
            store.AddManager(TEST_MANAGER, TEST_OWNER, context);
            item    = store.AddItem("existing", 2, categories1, 3.55, context);
            itemID  = item.Id;
            storeID = store.Id;
        }
Ejemplo n.º 22
0
        public void SearchItems_ByName_NameCorrect_ShouldPass()
        {
            using var context = new MarketDbContext(inMemoryConnection);
            Store[] stores = DataForTests.CreateStoresForSearchTests(storeHandler, context);

            Dictionary <Guid, ReadOnlyCollection <Item> > results =
                searchFacade.SearchItems(
                    context: context,
                    filterItemRank: null,
                    filterMinPrice: null,
                    filterMaxPrice: null,
                    filterStoreRank: null,
                    name: "item one");

            Assert.AreEqual(3, results.Keys.Count);

            ReadOnlyCollection <Item> resultStore  = results[stores[0].Id];
            ReadOnlyCollection <Item> resultStore1 = results[stores[1].Id];
            ReadOnlyCollection <Item> resultStore2 = results[stores[2].Id];

            Assert.AreEqual("item one", resultStore[0].Name);
            Assert.AreEqual("item one", resultStore1[0].Name);
            Assert.AreEqual("item one", resultStore2[0].Name);

            Assert.AreEqual(1, resultStore.Count);
            Assert.AreEqual(1, resultStore1.Count);
            Assert.AreEqual(1, resultStore2.Count);
        }
Ejemplo n.º 23
0
        public void OrderManager_ValidOrder_ShouldPass()
        {
            using var context = new MarketDbContext(inMemoryConnection);

            string storeName = GetStoreName();
            // setup test
            StoreContactDetails details = new StoreContactDetails(storeName, "*****@*****.**", "location", "222", "222", "bank", "cool store");

            storeHandler.OpenStore(details, Owner, context);
            Store s = storeHandler.Stores(context).Where(s => s.ContactDetails.Name.Equals(storeName, StringComparison.InvariantCultureIgnoreCase)).First();

            string itemName = "testItemD";
            Item   item     = s.AddItem(itemName, 2, new HashSet <string>()
            {
                "CategoryA"
            }, 1.22, context);

            Dictionary <Guid, StoreCart> shoppingCart = new Dictionary <Guid, StoreCart>();
            StoreCart cart = new StoreCart(s.Id);

            cart.AddToStoreCart(item.Id, 1);
            shoppingCart.Add(s.Id, cart);

            // test
            Order order = null;

            Assert.DoesNotThrow(() => order = orderManager.DiscountAndReserve(Buyer1, shoppingCart, context));
            Assert.IsNotNull(order);
            order.Status = OrderStatus.DELIVERED;
            Assert.DoesNotThrow(() => orderManager.LogOrder(order.UserId, order.OrderId, context));
        }
Ejemplo n.º 24
0
        private void button10_Click(object sender, EventArgs e)
        {
            string          musteriadi = " ";
            string          soyadi     = " ";
            MarketDbContext db         = new MarketDbContext();

            foreach (var deger in db.Musteris)
            {
                if (deger.MusteriID == Convert.ToInt32(textBox4.Text))
                {
                    musteriadi = deger.MusteriAd;
                    soyadi     = deger.MusteriSoyad;
                }
            }
            var cntxt = new MarketDbContext();

            _ = cntxt.Borcs.Add(new Moduls.Entity.Borc
            {
                MusteriAd    = musteriadi,
                MusteriSoyad = soyadi,
                MusteriID    = Convert.ToInt32(textBox4.Text),
                MusteriOdeme = Convert.ToInt32(textBox2.Text),
                //SatinAlmaTarihi = Convert.ToDateTime(textBox8.Text),
            });
        }
Ejemplo n.º 25
0
        public void OrderManager_Delivery_Guest_ShouldPass()
        {
            using var context = new MarketDbContext(inMemoryConnection);

            string storeName = GetStoreName();
            // setup test
            StoreContactDetails details = new StoreContactDetails(storeName, "*****@*****.**", "location", "222", "222", "bank", "cool store");

            storeHandler.OpenStore(details, Owner, context);
            Store s = storeHandler.Stores(context).Where(s => s.ContactDetails.Name.Equals(storeName, StringComparison.InvariantCultureIgnoreCase)).First();

            string itemName = "testItemD";
            Item   item     = s.AddItem(itemName, 2, new HashSet <string>()
            {
                "CategoryA"
            }, 1.22, context);

            Dictionary <Guid, StoreCart> shoppingCart = new Dictionary <Guid, StoreCart>();
            StoreCart cart = new StoreCart(s.Id);

            cart.AddToStoreCart(item.Id, 1);
            shoppingCart.Add(s.Id, cart);

            DeliveryReal realDelivery = new DeliveryReal(new HttpClient());

            orderManager.Delivery.Real = realDelivery;
            Order order = null;

            Assert.DoesNotThrow(() => order = orderManager.DiscountAndReserve(GetGuestId(), shoppingCart, context));
            Assert.IsNotNull(order);
            order.Status = OrderStatus.PAYED_FOR;
            Assert.DoesNotThrow(() => orderManager.ScheduleDelivery(order.userKey, order.OrderId, "address", "city", "country", "22222", "name", context));
        }
Ejemplo n.º 26
0
        private void button10_Click(object sender, EventArgs e)
        {
            Borc bilgi = new Borc();
            // bilgi.KalanBorc = bilgi.KalanBorcOlustur();
            MarketDbContext cntxt    = new MarketDbContext();
            int             Id       = Convert.ToInt32(textBox3.Text);
            var             guncelle = cntxt.Borcs.Where(w => w.BorcID == Id).FirstOrDefault();

            guncelle.MusteriOdeme += Convert.ToDouble(textBox2.Text);
            guncelle.KalanBorc     = Convert.ToDouble(textBox1.Text);
            // bilgi.KalanBorc = bilgi.KalanBorcOlustur();
            cntxt.SaveChanges();
            bilgi.KalanBorc = bilgi.KalanBorcOlustur();
            MessageBox.Show("ödeme gerçekleştirldi");


            /* MarketDbContext cntx = new MarketDbContext();
             * Borc borcMus = new Borc
             * {
             *   MusteriID = Convert.ToInt32(comboBox1.SelectedItem),
             *   MusteriOdeme = Convert.ToInt32(textBox2.Text)
             * };
             * cntx.Borcs.Add(borcMus);
             * cntx.SaveChanges();
             * MessageBox.Show("ödeme gerçekleştirldi"); */
        }
 //delete buttun: delete any product in DB
 private void btn_delete_Click(object sender, EventArgs e)
 {
     try
     {
         if (_Id != -1)
         {
             using (MarketDbContext marketDbContext = new MarketDbContext())
             {
                 Model.TopSellingStation _TopSellingStation = marketDbContext.TopSellingStations.Where(x => x.Id == _Id).FirstOrDefault();
                 marketDbContext.TopSellingStations.Remove(_TopSellingStation);
                 marketDbContext.SaveChanges();
                 dataGrid_allProduct.DataSource = marketDbContext.TopSellingStations.ToList();
                 _Id = -1;
             }
             //on double click 'add button' will visibility=false. So must be now visibility=true
             btn_add.Enabled = true;
         }
     }
     catch (Exception exp)
     {
         MessageBox.Show(exp.Message);
     }
     finally
     {
         Clear();
     }
 }
Ejemplo n.º 28
0
        private void button8_Click(object sender, EventArgs e)
        {
            MarketDbContext db      = new MarketDbContext();
            var             müsteri = db.Musteris.ToList();

            dataGridView1.DataSource = müsteri;
        }
Ejemplo n.º 29
0
 public void LogoutThenLogin_RegisteredUser_ShouldPass()
 {
     LoginRegisteredSession();
     using var context = new MarketDbContext(inMemoryConnection);
     Assert.DoesNotThrow(() => manager.Logout(registeredUser, context));
     Assert.DoesNotThrow(() => manager.Login(SESSIONID, registeredUser, TEST_USERNAME, TEST_PASSWORD, context));
 }
Ejemplo n.º 30
0
        private void btnDeleteVillage_Click(object sender, EventArgs e)
        {
            try
            {
                if (selectedRow == null)
                {
                    MessageBox.Show("اختر مصروف للحذف", "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                DialogResult result = MessageBox.Show("هل تريد المتابعه فى الحذف ؟", "تأكيد", MessageBoxButtons.YesNoCancel);
                if (result == DialogResult.Yes)
                {
                    using (var db = new MarketDbContext())
                    {
                        var id = int.Parse(selectedRow.Cells[1].Value.ToString());

                        db.DailyCosts.Remove(db.DailyCosts.FirstOrDefault(x => x.DailyCostId == id));
                        btnDeleteDailyCost.Enabled = false;
                        db.SaveChanges();
                    }
                    btnDeleteDailyCost.Enabled = true;
                    DailyCostDataGrid.Rows[selectedRow.Index].Delete();
                    MessageBox.Show("تم الحذف بنجاح", "تم", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show("عذرا حدث خطأ ما", "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }