Ejemplo n.º 1
0
 public async Task ShowParams(GoodCategory item)
 {
     await Page.Navigation.PushAsync(new SimpleTablePage()
     {
         ViewModel = new GoodPropertyListViewModel(item)
     });
 }
Ejemplo n.º 2
0
        public void GetGoodsCategories_AddTwoGoodsCategories_ReturnedSameGoodsCategories()
        {
            DataService  Service       = new DataService();
            GoodCategory GoodCategory1 = new GoodCategory();

            GoodCategory1.Description = "NameTest2";
            GoodCategory1.Name        = "TestName2";

            GoodCategory GoodCategory2 = new GoodCategory();

            GoodCategory2.Description = "NameTest2";
            GoodCategory2.Name        = "TestName2";

            ClearTestDocument(Services.Formatter.GetPathForType(typeof(GoodCategory)));

            Service.AddItem(GoodCategory1);
            Service.AddItem(GoodCategory2);

            GoodCategory[] LoadedGoodCategories = Service.GetGoodsCategoryes();
            if (LoadedGoodCategories.Length != 2)
            {
                Assert.Fail();
            }

            Assert.AreEqual(LoadedGoodCategories[0], GoodCategory1);
            Assert.AreEqual(LoadedGoodCategories[1], GoodCategory2);
        }
Ejemplo n.º 3
0
        public static GoodCategory[] GetCategories()
        {
            GoodCategory[] Categories = new GoodCategory[]
            {
                new GoodCategory
                {
                    Name      = "Books",
                    TaxExempt = true
                },
                new GoodCategory
                {
                    Name      = "Food",
                    TaxExempt = true
                },
                new GoodCategory
                {
                    Name      = "Medical",
                    TaxExempt = true
                },
                new GoodCategory
                {
                    Name      = "Music",
                    TaxExempt = false
                },
                new GoodCategory
                {
                    Name      = "Perfume",
                    TaxExempt = false
                }
            };

            return(Categories);
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("ParentId,Descr,Id")] GoodCategory goodCategory)
        {
            if (id != goodCategory.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(goodCategory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GoodCategoryExists(goodCategory.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ParentId"] = new SelectList(_context.Categories, "Id", "Id", goodCategory.ParentId);
            return(View(goodCategory));
        }
Ejemplo n.º 5
0
        public Good(string name, double price, GoodCategory category, string description, bool taxable)
        {
            Name        = name;
            Price       = price;
            Category    = category;
            Description = description;
            Taxable     = taxable;

            if (this.Taxable == true)
            {
                if (Category == GoodCategory.Food || Category == GoodCategory.Pharmaceutical || Category == GoodCategory.Clothing)
                {
                    tax = Price * 0.05;
                }
                else if (Category == GoodCategory.Electronics || Category == GoodCategory.Furniture || Category == GoodCategory.OfficeSupplies || Category == GoodCategory.Tools)
                {
                    tax = Price * 0.09;
                }
                else if (Category == GoodCategory.CigarettesOrAlcohol)
                {
                    tax = Price * 1.19;
                }
            }
            else
            {
                tax = 0;
            }
        }
Ejemplo n.º 6
0
 public EditCategoryViewModel(GoodCategory category, HttpClient httpClient, Page page)
 {
     this.category = category;
     requestHelper = new RequestHelper(httpClient);
     sessionData   = new SessionDataStore();
     SaveCommand   = new Command(SaveCategory, CanSave);
     this.page     = page;
 }
Ejemplo n.º 7
0
        public async Task <IActionResult> AddOrUpdate(GoodCategory categories)
        {
            ViewData["DataType"] = typeof(FileEntry);
            var _fileEntry = await goodsBusiness.AddGoodCategory(categories);

            ViewData["DataModel"] = _fileEntry;
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 8
0
        public void AddItem()
        {
            GoodCategory NewItem  = new GoodCategory();
            Guid         ObjectId = Service.AddItem(NewItem);

            SetTabDelegate.Invoke(new DataEditTab(Service, SetTabDelegate, this, ObjectId, typeof(GoodCategory)), AddMainButtons: false);

            UpdateElements();
        }
        public void Add(AddGoodCategoryDto dto)
        {
            var goodCategory = new GoodCategory
            {
                Title = dto.Title,
            };

            _goodCategoryRepository.Add(goodCategory);

            _unitOfWork.Complete();
        }
        public async Task <IActionResult> Create([Bind("ParentId,Descr,Id")] GoodCategory goodCategory)
        {
            if (ModelState.IsValid)
            {
                goodCategory.Id = Guid.NewGuid();
                _context.Add(goodCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ParentId"] = new SelectList(_context.Categories, "Id", "Id", goodCategory.ParentId);
            return(View(goodCategory));
        }
Ejemplo n.º 11
0
        public async Task DeleteCategory(GoodCategory item)
        {
            await requestHelper.Delete <GoodCategory>($"http://rstore.kikoriki.space/GoodCategory/{ sessionData.SessionToken }/{ item.ID }");

            foreach (var i in Elements)
            {
                if (item == i.getModelItem())
                {
                    Elements.Remove(i); break;
                }
            }
            await Page.DisplayAlert("Delete Category success!", item.Name, "Ok");
        }
Ejemplo n.º 12
0
        public void GetGoodsCategory_AddGoodsCategoryReturnedGuid_ReturnedSameGoodsCategory()
        {
            DataService  Service      = new DataService();
            GoodCategory GoodCategory = new GoodCategory();

            GoodCategory.Description = "NameTest";
            GoodCategory.Name        = "TestName";
            ClearTestDocument(Services.Formatter.GetPathForType(typeof(GoodCategory)));

            Guid         AddedGuid          = Service.AddItem(GoodCategory);
            GoodCategory LoadedGoodCategory = Service.GetGoodsCategory(AddedGuid);

            Assert.AreEqual(GoodCategory, LoadedGoodCategory);
        }
Ejemplo n.º 13
0
        public async Task Add(AddGoodCategoryDto dto)
        {
            if (await _goodCategoryRepository.IsExistTitle(dto.Title))
            {
                throw new Exception();
            }

            GoodCategory goodCategory = new GoodCategory();

            goodCategory.Title = dto.Title;

            _goodCategoryRepository.Add(goodCategory);
            _unitOfWork.Complete();
        }
Ejemplo n.º 14
0
        public EditGoodProperty(GoodCategory goodCategory, GoodProperty goodProperty = null)
        {
            InitializeComponent();
            if (goodProperty == null)
            {
                goodProperty = new GoodProperty()
                {
                    GoodCategoryID = goodCategory.ID
                }
            }
            ;

            model          = new EditGoodPropertyViewModel(goodCategory, goodProperty, new HttpClient(), this);
            BindingContext = model;
        }
        public async Task AddGoodCategory(string Title)
        {
            if (GoodCaterotyDublicate(Title))
            {
                throw new GoodCategoryTitleCantBeDuplicated();
            }

            var goodCategory = new GoodCategory
            {
                Title = Title
            };

            _repository.AddGoodCategory(goodCategory);
            _unitOfWork.Complete();
        }
Ejemplo n.º 16
0
        public GoodPropertyListViewModel(GoodCategory goodCategory)
        {
            this.goodCategory = goodCategory;

            var buttons = new ToolbarItem[1];

            buttons[0]   = new ToolbarItem("Add", "", AddProperty);
            ToolbarItems = buttons;

            sessionData = new SessionDataStore();

            requestHelper = new RequestHelper();

            Elements = new ObservableCollection <IExecutableModel>();
        }
Ejemplo n.º 17
0
        public void Add([Required][FromBody] string Title)
        {
            if (_context.GoodCategories.Any(_ => _.Title == Title))
            {
                throw new GoodCategoryTitleCantBeDuplicatedExcption();
            }
            var goodCategory = new GoodCategory
            {
                Title = Title
            };

            _context.GoodCategories.Add(goodCategory);

            _context.SaveChanges();
        }
Ejemplo n.º 18
0
        public async Task Add([Required][FromBody] string title)
        {
            if (await _GoodCategoryRepository.IsGoodCategoryDuplicatedAsync(title))
            {
                throw new GoodCategoryTitleCantBeDuplicatedExcption();
            }

            var goodCategory = new GoodCategory
            {
                Title = title
            };

            await _GoodCategoryRepository.AddAsync(goodCategory);
           await  _unitOfWork.CompleteAsync();
        }
Ejemplo n.º 19
0
        public void TestSales()
        {
            var cat1=new GoodCategory("cat1");
            var cat2=new GoodCategory("cat2");
            var cat3=new GoodCategory("cat3");
            var cat4=new GoodCategory("cat4");

            var listcat1=new List<GoodCategory>() {
                            new GoodCategory("cat2")
                        };

            var listcat12=new List<GoodCategory>() {
                        new GoodCategory("cat1"),
                        new GoodCategory("cat2")
                    };

            taxes= new System.Collections.Generic.List<SalesTax>( ) {
                    new SalesTax( "tax5",5,listcat1),
                    new SalesTax( "tax10",10,listcat12)
            };
            Good good = new Good("good1", 10M, cat1);
            Good good2 = new Good("good2", 13.11M, cat1);
            Good good3 = new Good("good3", 17.01M, cat2);
            SalesTaxManager salestaxmgr = new SalesTaxManager(taxes);
            /***
             *  total= 10 + rounttoupper0.05(10 * 10 /100) = 10 + rounttoupper0.5(1) =10 +1 =11
             * */
            Assert.AreEqual(1M, salestaxmgr.computeTax(good));

            Assert.AreEqual( 11M, salestaxmgr.computeTotal(good));
            /***
             *  total= 13.11 + rounttoupper0.05(13.11 * 10 /100)
             *       = 13.11 + rounttoupper0.05(1.311)
             *       = 13.11 + 1.35 = 14.46
             * */
            Assert.AreEqual(1.35M, salestaxmgr.computeTax(good2));

            Assert.AreEqual(14.46M ,salestaxmgr.computeTotal(good2) );

            /***
             *  total= 17.01 + rounttoupper0.05(17.01 * 10 /100) +rounttoupper0.05(17.01  * 5 /100)
             *       = 17.01  + rounttoupper0.05(1.701) + rounttoupper0.05(0.08505)
             *       = 17.01  + 1.75 + 0.9 =
             *       = 17.01 + 2.65 =  19.66
             * */
            Assert.AreEqual(2.65M, salestaxmgr.computeTax(good3));
            Assert.AreEqual( 19.66M ,salestaxmgr.computeTotal(good3));
        }
Ejemplo n.º 20
0
        public async Task <ApiMessage> AddGoodCategory(GoodCategory category)
        {
            var resultMsg = new ApiMessage();

            try
            {
                await DataGoodsAccessor.Add(category);
            }
            catch (Exception exc)
            {
                resultMsg.Success = false;
                resultMsg.Message = exc.Message;
                return(resultMsg);
            }
            return(resultMsg);
        }
Ejemplo n.º 21
0
        public void UpdateQuality()
        {
            foreach (var item in Items)
            {
                if (IsSulfuras(item))
                {
                    continue;
                }

                item.SellIn -= 1;
                var quality = new Quality(item.Quality);
                var good    = new GoodCategory().BuildFor(item);
                good.Update(quality);
                item.Quality = quality.Amount;
            }
        }
        private void LoadSuppliers()
        {
            string           querry     = "SELECT * FROM supplier";
            SQLiteConnection connection = new SQLiteConnection(connectionString);

            using (SQLiteCommand command = new SQLiteCommand(querry, connection))
            {
                connection.Open();
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        long     id             = (long)reader["id"];
                        string   s_name         = (string)reader["s_name"];
                        int      inregistration = Convert.ToInt32(reader["s_inregistration"]);
                        string   bank           = (string)reader["s_bank"];
                        string   headquaters    = (string)reader["headquaters"];
                        string   phone          = (string)reader["s_phone"];
                        string   employee       = (string)reader["employee"];
                        Supplier supplier       = new Supplier(id, s_name, inregistration, bank, headquaters, employee, phone);

                        string goodsQuerry = $"Select * from good where supplier_id={id}";
                        using (SQLiteCommand goodCommand = new SQLiteCommand(goodsQuerry, connection))
                        {
                            using (var goodReader = goodCommand.ExecuteReader())
                            {
                                while (goodReader.Read())
                                {
                                    long         g_id        = (long)goodReader["g_id"];
                                    string       g_name      = (string)goodReader["g_name"];
                                    double       price       = Convert.ToDouble(goodReader["g_price"]);
                                    string       description = (string)goodReader["g_description"];
                                    bool         taxable     = bool.Parse(goodReader["taxable"].ToString());
                                    GoodCategory category    = (GoodCategory)Convert.ToInt32(goodReader["category"]);
                                    Good         good        = new Good(g_id, g_name, price, category, description, taxable);
                                    supplier.AddGood(good);
                                }
                            }
                        }

                        suppliers.Add(supplier);
                    }
                }
            }
        }
Ejemplo n.º 23
0
        public async Task <ApiMessage> UpdateCategory(GoodCategory category)
        {
            var resultMsg = new ApiMessage();

            try
            {
                var cate = await DataGoodsAccessor.Update <GoodCategory>(category);

                resultMsg.Data = cate;
            }
            catch (Exception exc)
            {
                resultMsg.Success = false;
                resultMsg.Message = exc.Message;
                return(resultMsg);
            }
            return(resultMsg);
        }
        private void loadContracts()
        {
            string           querry     = "SELECT * FROM contract c JOIN supplier s on  c.supplier_id=s.id join good g on c.good_id = g.g_id; ";
            SQLiteConnection connection = new SQLiteConnection(connectionString);

            using (SQLiteCommand command = new SQLiteCommand(querry, connection))
            {
                connection.Open();
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        long     c_id    = (long)reader["c_id"];
                        string   c_name  = (string)reader["c_name"];
                        string   c_phone = (string)reader["c_phone"];
                        string   c_bank  = (string)reader["c_bank"];
                        int      noGoods = Convert.ToInt32(reader["no_goods"]);
                        DateTime c_date  = DateTime.Parse(reader["c_date"].ToString());


                        string s_name           = (string)reader["s_name"];
                        int    s_inregistration = Convert.ToInt32(reader["s_inregistration"]);
                        string s_bank           = (string)reader["s_bank"];
                        string s_headquaters    = (string)reader["headquaters"];
                        string s_phone          = (string)reader["s_phone"];
                        string s_employee       = (string)reader["employee"];

                        string       g_name        = (string)reader["g_name"];
                        double       g_price       = Convert.ToDouble(reader["g_price"]);
                        string       g_description = (string)reader["g_description"];
                        bool         g_taxable     = bool.Parse(reader["taxable"].ToString());
                        GoodCategory g_category    = (GoodCategory)Convert.ToInt32(reader["category"]);

                        Supplier supplier = new Supplier(s_name, s_inregistration, s_bank, s_headquaters, s_employee, s_phone);
                        Good     good     = new Good(g_name, g_price, g_category, g_description, g_taxable);
                        Contract contract = new Contract(c_id, c_name, c_phone, c_bank, supplier, noGoods, good, c_date);


                        contracts.Add(contract);
                    }
                }
            }
        }
Ejemplo n.º 25
0
        public void Sort(String FieldName)
        {
            switch (FieldName)
            {
            case "Name":
                Elements.Sort((x, y) => {
                    GoodCategory obj  = Service.GetGoodsCategory(x.ObjectId);
                    GoodCategory obj2 = Service.GetGoodsCategory(y.ObjectId);
                    return(obj.Name.CompareTo(obj2.Name));
                });
                break;

            case "Description":
                Elements.Sort((x, y) => {
                    GoodCategory obj  = Service.GetGoodsCategory(x.ObjectId);
                    GoodCategory obj2 = Service.GetGoodsCategory(y.ObjectId);
                    return(obj.Description.CompareTo(obj2.Description));
                });
                break;
            }
        }
Ejemplo n.º 26
0
        public void RemoveItem_AddGoodsCategory_GoodsCategoryWillBeRemovedAndHisIdWillBeRemovedFromAllGoods()
        {
            //arrange
            DataService  Service       = new DataService();
            GoodCategory GoodsCategory = new GoodCategory();

            ClearTestDocument(Services.Formatter.GetPathForType(typeof(Good)));
            ClearTestDocument(Services.Formatter.GetPathForType(typeof(GoodCategory)));
            Guid AddedCategoryGuid = Service.AddItem(GoodsCategory);

            Good Good1 = new Good();

            Good1.CategoryesIds = new Guid[] { Guid.NewGuid(), AddedCategoryGuid };
            Guid Good1AddedGuid = Service.AddItem(Good1);

            Good Good2 = new Good();

            Good2.CategoryesIds = new Guid[] { Guid.NewGuid(), Guid.NewGuid() };
            Guid Good2AddedGuid = Service.AddItem(Good2);

            //act
            Service.RemoveItem(typeof(GoodCategory), AddedCategoryGuid);
            GoodCategory LoadedGoodsCategory = Service.GetGoodsCategory(AddedCategoryGuid);

            Good[] LoadedGoods = Service.GetGoods();


            //assert
            if (LoadedGoodsCategory != null)
            {
                Assert.Fail();
            }
            if (!LoadedGoods[0].GUID.Equals(Good1AddedGuid) ||
                !LoadedGoods[1].GUID.Equals(Good2AddedGuid) ||
                LoadedGoods[0].CategoryesIds.Any(item => item.Equals(AddedCategoryGuid)))
            {
                Assert.Fail();
            }
        }
Ejemplo n.º 27
0
        private async Task GoodCategroySeedAsync()
        {
            var num = await _repoGoodCategory.GetCountAsync();

            if (num == 0)
            {
                var goodCategoryId = _guidGenerator.Create();
                goodCategory = new GoodCategory(
                    goodCategoryId,
                    "休闲零食",
                    "ls",
                    "",
                    "",
                    null,
                    null
                    );
                goodCategory = await _repoGoodCategory.InsertAsync(goodCategory);
            }
            else
            {
                goodCategory = _repoGoodCategory.FirstOrDefault();
            }
        }
Ejemplo n.º 28
0
 public void Add(GoodCategory goodCategory)
 {
     _dBCOntext.GoodCategories.Add(goodCategory);
 }
Ejemplo n.º 29
0
        public async Task <IActionResult> AddGoodCategory(GoodCategory category)
        {
            var result = await goodsBs.AddGoodCategory(category);

            return(Json(result));
        }
Ejemplo n.º 30
0
 /// <summary>
 /// Verify if a sale tax is appliable to a certain good category
 /// </summary>
 /// <param name="category"></param>
 /// <returns></returns>
 public bool IsAppliableTo(GoodCategory category)
 {
     if (_categories_excluded.Any( item => item.Equals(category))) return false;
     if (_categories_included.Any(item => item.Equals(category))) return true;
     return false;
 }
Ejemplo n.º 31
0
 public void IncludeGoodCategory(GoodCategory gc)
 {
     _categories_included.Add(gc);
 }
Ejemplo n.º 32
0
 public void ExcludeGoodCategory(GoodCategory gc)
 {
     _categories_excluded.Add(gc);
 }
Ejemplo n.º 33
0
 public void Delete(GoodCategory goodCategory)
 {
     _setGoodCategory.Remove(goodCategory);
 }
Ejemplo n.º 34
0
        static void Main(string[] args)
        {
            GoodCategory generic_category = new GoodCategory("generic");
            GoodCategory book_category = new GoodCategory("book");
            GoodCategory food_category = new GoodCategory("food");
            GoodCategory medical_product_category = new GoodCategory("medical_product");
            GoodCategory imported_good_category= new GoodCategory("imported");

            List<GoodCategory> all_categories = new List<GoodCategory>();
            all_categories.Add(generic_category);
            all_categories.Add(book_category);
            all_categories.Add(food_category);
            all_categories.Add(medical_product_category);
            all_categories.Add(imported_good_category);

            List<GoodCategory> imported_categories = new List<GoodCategory>();
            imported_categories.Add(imported_good_category);

            SalesTax basic_tax = new SalesTax("basic sale tax", 10, all_categories);

            basic_tax.ExcludeGoodCategory(book_category);
            basic_tax.ExcludeGoodCategory(food_category);
            basic_tax.ExcludeGoodCategory(medical_product_category);

            SalesTax import_tax = new SalesTax("import sale tax", 5 , imported_categories);

            List<SalesTax> taxes = new List<SalesTax>();

            taxes.Add(import_tax);
            taxes.Add(basic_tax);

            List<GoodCategory> imported_foods = new List<GoodCategory>();
            imported_foods.Add(food_category);
            imported_foods.Add(imported_good_category);

            List<GoodCategory> imported_generic_goods = new List<GoodCategory>();
            imported_generic_goods.Add(generic_category);
            imported_generic_goods.Add(imported_good_category);

            List<Good> input1= new List<Good>();
            input1.Add(new Good("1 book", 12.49M,book_category));
            input1.Add(new Good("1 music CD", 14.99M , generic_category));
            input1.Add(new Good("1 chocolate bar",0.85M ,  food_category));

            List<Good> input2= new List<Good>();
            input2.Add(new Good("1 imported box of chocolates", 10.0M ,imported_foods));
            input2.Add(new Good("1 imported bottle of perfume", 47.5M, imported_generic_goods));

            List<Good> input3= new List<Good>();
            input3.Add(new Good("1 imported bottle of perfume", 27.99M, imported_generic_goods));
            input3.Add(new Good("1 bottle of perfume", 18.99M, generic_category));
            input3.Add(new Good("1 packet of headache pills", 9.75M, medical_product_category));
            input3.Add(new Good("1 box of imported chocolates", 11.25M, imported_foods));

            Dictionary<string,List<Good>> inputs = new Dictionary<string,List<Good>>();
            inputs.Add("Input 1", input1);
            inputs.Add("Input 2", input2);
            inputs.Add("Input 3", input3);
            Console.WriteLine("INPUT:");

            foreach (var input in inputs)
            {
                Console.WriteLine();
                Console.WriteLine(input.Key+":");
                foreach (Good good in input.Value)
                {
                    Console.WriteLine(good.priceToString())  ;
                }
                Console.WriteLine();
                Console.WriteLine("Press any key to continue");
                Console.ReadKey();

            }

            Console.WriteLine();
            Console.WriteLine("OUTPUT:");
            SalesTaxManager stmgr = new SalesTaxManager(taxes);
            var i = 1;
            foreach (var input in inputs)
            {
                stmgr.resetTotals();
                Console.WriteLine();
                Console.WriteLine("Output "+i +":");
                foreach (var good in input.Value)
                {
                    stmgr.addTax(good);
                    stmgr.addAmount(good);

                    Console.WriteLine(stmgr.totalGoodToString(good));

                }
                Console.WriteLine(stmgr.totalTaxesToString());
                Console.WriteLine(stmgr.totalToString());
                Console.WriteLine();
                Console.WriteLine("Press any key to continue");

                Console.ReadKey();
                i++;
            }
        }
Ejemplo n.º 35
0
 public async Task EditCategory(GoodCategory item)
 {
     await Page.Navigation.PushAsync(new EditCategory(item));
 }