예제 #1
0
        //Delete a record
        public IActionResult DeleteRecord(int id)
        {
            SQLTaxData sqlData = new SQLTaxData(_context);

            sqlData.Delete(id);
            return(new RedirectResult("/"));
        }
예제 #2
0
        //Index page showning all the records.
        public IActionResult Index()
        {
            //Initial testing
            //var taxEntity = new Tax {PersonName = "Apie", AnnualIncome = 20000d, PostalCode = "7000", RecordDate = DateTime.Now };
            //taxEntity.CalculateTax();
            //sqlData.Add(taxEntity);

            SQLTaxData sqlData = new SQLTaxData(_context);

            var model = new HomePageViewModel();

            model.Taxes = sqlData.GetAll();
            model.tax   = new TaxAddViewModel();

            return(View(model));
        }
예제 #3
0
        public IActionResult AddRecord(TaxAddViewModel input)
        {
            SQLTaxData sqlData = new SQLTaxData(_context);

            if (ModelState.IsValid)
            {
                Tax tax = new Tax();
                tax.PersonName   = input.PersonName;
                tax.AnnualIncome = input.AnnualIncome;
                tax.PostalCode   = input.PostalCode;
                tax.RecordDate   = DateTime.Now;
                tax.CalculateTax();

                sqlData.Add(tax);
            }
            return(new RedirectResult("/"));
        }