public async Task <IActionResult> Edit(int id, [Bind("CalculatedTaxID,Value")] CalculatedTax calculatedTax)
        {
            CalculatedTax updateRec = _context.CalculatedTaxes.Where(x => x.CalculatedTaxID == id && x.IsDeleted == false).FirstOrDefault();

            if (id != calculatedTax.CalculatedTaxID | updateRec == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    updateRec.Value            = calculatedTax.Value;
                    updateRec.LastModifiedBy   = "System";
                    updateRec.LastModifiedDate = DateTime.Now;

                    _context.Update(updateRec);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CalculatedTaxExists(calculatedTax.CalculatedTaxID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(calculatedTax));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ProgressiveTaxID,Rate,From,To")] ProgressiveTax progressiveTax)
        {
            ProgressiveTax updateRec = _context.ProgressiveTaxes.Where(x => x.ProgressiveTaxID == id && x.IsDeleted == false).FirstOrDefault();

            if (id != progressiveTax.ProgressiveTaxID | updateRec == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    updateRec.Rate             = progressiveTax.Rate;
                    updateRec.From             = progressiveTax.From;
                    updateRec.To               = progressiveTax.To;
                    updateRec.LastModifiedBy   = "System";
                    updateRec.LastModifiedDate = DateTime.Now;

                    _context.Update(updateRec);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProgressiveTaxExists(progressiveTax.ProgressiveTaxID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(progressiveTax));
        }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("TaxTypeID,Description,Code")] TaxType taxType)
        {
            TaxType updateRec = _context.TaxTypes.Where(x => x.TaxTypeID == id && x.IsDeleted == false).FirstOrDefault();

            if (id != taxType.TaxTypeID | updateRec == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    updateRec.Description      = taxType.Description;
                    updateRec.Code             = taxType.Code;
                    updateRec.LastModifiedBy   = "System"; //In place should user roles become a factor
                    updateRec.LastModifiedDate = DateTime.Now;

                    _context.Update(updateRec);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TaxTypeExists(taxType.TaxTypeID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(taxType));
        }
        public async Task <IActionResult> Edit(int id, [Bind("PostalCodeID,Value,TaxTypeID")] PostalCode postalCode)
        {
            PostalCode updateRec = _context.PostalCodes.Where(x => x.PostalCodeID == postalCode.PostalCodeID && x.IsDeleted == false).FirstOrDefault();

            if (id != postalCode.PostalCodeID | updateRec == null)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    updateRec.Value            = postalCode.Value;
                    updateRec.TaxTypeID        = _context.TaxTypes.Where(x => x.TaxTypeID == int.Parse(ModelState["TaxTypeID"].RawValue.ToString())).FirstOrDefault().TaxTypeID;
                    updateRec.LastModifiedBy   = "System";
                    updateRec.LastModifiedDate = DateTime.Now;

                    _context.Update(updateRec);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PostalCodeExists(postalCode.PostalCodeID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(postalCode));
        }