public async Task <IActionResult> Create([Bind("CalculatedTaxID,Value")] CalculatedTax calculatedTax)
        {
            if (ModelState.IsValid)
            {
                calculatedTax.CreatedDate = calculatedTax.LastModifiedDate = DateTime.Now;
                calculatedTax.CreatedBy   = calculatedTax.LastModifiedBy = "System";

                _context.Add(calculatedTax);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(calculatedTax));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("TaxTypeID,Description,Code")] TaxType taxType)
        {
            if (_context.TaxTypes.Where(x => x.Code == taxType.Code && x.IsDeleted == false) != null)
            {
                return(Forbid()); //Duplicate record
            }
            if (ModelState.IsValid)
            {
                taxType.CreatedDate = taxType.LastModifiedDate = DateTime.Now;
                taxType.CreatedBy   = taxType.LastModifiedBy = "System";
                taxType.IsDeleted   = false;

                _context.Add(taxType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(taxType));
        }
        public async Task <IActionResult> Create([Bind("PostalCodeID,Value,TaxTypeID")] PostalCode postalCode)
        {
            if (_context.PostalCodes.Where(x => x.Value == postalCode.Value && x.IsDeleted == false) != null)
            {
                return(Forbid()); //Duplicate record
            }
            if (ModelState.IsValid)
            {
                postalCode.TaxTypeID   = _context.TaxTypes.Where(x => x.TaxTypeID == int.Parse(ModelState["TaxTypeID"].RawValue.ToString())).FirstOrDefault().TaxTypeID;
                postalCode.CreatedDate = postalCode.LastModifiedDate = DateTime.Now;
                postalCode.CreatedBy   = postalCode.LastModifiedBy = "System";
                postalCode.IsDeleted   = false;

                _context.Add(postalCode);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(postalCode));
        }
        public async Task <IActionResult> Create([Bind("ProgressiveTaxID,Rate,From,To")] ProgressiveTax progressiveTax)
        {
            if (_context.ProgressiveTaxes.Where(x => x.Rate == progressiveTax.Rate && x.IsDeleted == false).FirstOrDefault() != null)
            {
                return(Forbid()); //Duplicate Rate
            }
            if (ModelState.IsValid)
            {
                progressiveTax.CreatedDate = progressiveTax.LastModifiedDate = DateTime.Now;
                progressiveTax.CreatedBy   = progressiveTax.LastModifiedBy = "System";
                progressiveTax.IsDeleted   = false;

                _context.Add(progressiveTax);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(progressiveTax));
        }
        public async Task SaveCalculatedTax(Models.TaxCalculationResult taxCalculationResult)
        {
            await _context.AddAsync(_mapper.Map <Entities.TaxCalculationResult>(taxCalculationResult));

            await _context.SaveChangesAsync();
        }