public async Task <IActionResult> Edit(int id, [Bind("PurchaseTaxTypeId,TaxName,TaxType,CompositeRate")] PurchaseTaxType purchaseTaxType)
        {
            if (id != purchaseTaxType.PurchaseTaxTypeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(purchaseTaxType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PurchaseTaxTypeExists(purchaseTaxType.PurchaseTaxTypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(PartialView(purchaseTaxType));
        }
        public async Task <ActionResult <PurchaseTaxType> > PostPurchaseTaxType(PurchaseTaxType purchaseTaxType)
        {
            _context.PurchaseTaxTypes.Add(purchaseTaxType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPurchaseTaxType", new { id = purchaseTaxType.PurchaseTaxTypeId }, purchaseTaxType));
        }
        public async Task <IActionResult> PutPurchaseTaxType(int id, PurchaseTaxType purchaseTaxType)
        {
            if (id != purchaseTaxType.PurchaseTaxTypeId)
            {
                return(BadRequest());
            }

            _context.Entry(purchaseTaxType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PurchaseTaxTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#4
0
        public int CreatePurchaseTaxType(VoyagerContext db, ImportPurchase purchase, bool IsLocal = false)
        {
            //Calculate tax rate
            int taxRate = 0;

            taxRate = (int)((purchase.TaxAmt * 100) / purchase.CostValue);

            if (IsLocal)
            {
                try
                {
                    int id = db.PurchaseTaxTypes.Where(c => c.CompositeRate == taxRate).Select(c => c.PurchaseTaxTypeId).FirstOrDefault();
                    if (id == 0)
                    {
                        PurchaseTaxType taxType = new PurchaseTaxType {
                            CompositeRate = taxRate, TaxType = TaxType.GST, TaxName = "Input Tax GST(SGST+CGST) @" + taxRate
                        };
                        db.PurchaseTaxTypes.Add(taxType);
                        db.SaveChanges();
                        return(taxType.PurchaseTaxTypeId);
                    }
                    return(id);
                }
                catch (Exception)
                {
                    PurchaseTaxType taxType = new PurchaseTaxType {
                        CompositeRate = taxRate, TaxType = TaxType.GST, TaxName = "Input Tax GST(SGST+CGST) @" + taxRate
                    };
                    db.PurchaseTaxTypes.Add(taxType);
                    db.SaveChanges();
                    return(taxType.PurchaseTaxTypeId);
                }
            }


            try
            {
                int id = db.PurchaseTaxTypes.Where(c => c.CompositeRate == taxRate).Select(c => c.PurchaseTaxTypeId).FirstOrDefault();
                if (id == 0)
                {
                    PurchaseTaxType taxType = new PurchaseTaxType {
                        CompositeRate = taxRate, TaxType = TaxType.IGST, TaxName = "Input Tax IGST @" + taxRate
                    };
                    db.PurchaseTaxTypes.Add(taxType);
                    db.SaveChanges();
                    return(taxType.PurchaseTaxTypeId);
                }
                return(id);
            }
            catch (Exception)
            {
                PurchaseTaxType taxType = new PurchaseTaxType {
                    CompositeRate = taxRate, TaxType = TaxType.IGST, TaxName = "Input Tax IGST @" + taxRate
                };
                db.PurchaseTaxTypes.Add(taxType);
                db.SaveChanges();
                return(taxType.PurchaseTaxTypeId);
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            PurchaseTaxType purchaseTaxType = db.PurchaseTaxTypes.Find(id);

            db.PurchaseTaxTypes.Remove(purchaseTaxType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "PurchaseTaxTypeId,TaxName,TaxType,CompositeRate")] PurchaseTaxType purchaseTaxType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(purchaseTaxType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(purchaseTaxType));
 }
        public ActionResult Create([Bind(Include = "PurchaseTaxTypeId,TaxName,TaxType,CompositeRate")] PurchaseTaxType purchaseTaxType)
        {
            if (ModelState.IsValid)
            {
                db.PurchaseTaxTypes.Add(purchaseTaxType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(purchaseTaxType));
        }
        public async Task <IActionResult> Create([Bind("PurchaseTaxTypeId,TaxName,TaxType,CompositeRate")] PurchaseTaxType purchaseTaxType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(purchaseTaxType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(PartialView(purchaseTaxType));
        }
        // GET: PurchaseTaxTypes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PurchaseTaxType purchaseTaxType = db.PurchaseTaxTypes.Find(id);

            if (purchaseTaxType == null)
            {
                return(HttpNotFound());
            }
            return(View(purchaseTaxType));
        }