Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            const string sectionCode = "SYS-SELL-COMBINED-SCN";

            if (id == null)
            {
                return(NotFound());
            }
            #region Section Management

            var section = await _context.Sections.SingleOrDefaultAsync(s => s.SystemName == sectionCode);

            if (section == null)
            {
                return(NotFound(new
                {
                    error = "Could not locate section "
                }));
            }
            #endregion
            SaleDocument = await _context.SellDocuments.FindAsync(id);

            if (SaleDocument != null)
            {
                _context.SellDocLines.RemoveRange(_context.SellDocLines.Where(p => p.SellDocumentId == id));
                _context.TransactorTransactions.RemoveRange(_context.TransactorTransactions.Where(p => p.SectionId == section.Id && p.CreatorId == id));
                _context.WarehouseTransactions.RemoveRange(_context.WarehouseTransactions.Where(p => p.SectionId == section.Id && p.CreatorId == id));

                _context.SellDocuments.Remove(SaleDocument);

                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public ActionResult CreateSellDocument(SellDocument sellDocument)
        {
            db.Entry(sellDocument).State = EntityState.Added;

            db.SaveChanges();
            ViewBag.right = true;
            return(View());
        }
        public ActionResult EditSellDocument(int?id)
        {
            SellDocument sellDocument = db.SellDocuments.Find(id);

            ViewBag.Employees = db.Employees.ToList();
            ViewBag.Cars      = db.Cars.ToList();
            ViewBag.Clients   = db.Clients.ToList();

            return(View(sellDocument));
        }
        public ActionResult DeleteSellDocument(int id)
        {
            SellDocument sellDocument = db.SellDocuments.Find(id);

            if (sellDocument != null)
            {
                db.SellDocuments.Remove(sellDocument);
                db.SaveChanges();
            }
            ViewBag.Id = id;
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SaleDocument = await _context.SellDocuments
                           .Include(b => b.Company)
                           .Include(b => b.FiscalPeriod)
                           .Include(b => b.SellDocSeries)
                           .Include(b => b.SellDocType)
                           .Include(b => b.Section)
                           .Include(b => b.Transactor).FirstOrDefaultAsync(m => m.Id == id);

            if (SaleDocument == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            // const string sectionCode = "SYS-SELL-COMBINED-SCN";
            if (id == null)
            {
                return(NotFound());
            }

            SaleDocument = await _context.SellDocuments.FindAsync(id);

            if (SaleDocument != null)
            {
                _context.SellDocLines.RemoveRange(_context.SellDocLines.Where(p => p.SellDocumentId == id));
                _context.TransactorTransactions.RemoveRange(_context.TransactorTransactions.Where(p => p.CreatorSectionId == SaleDocument.SectionId && p.CreatorId == id));
                _context.WarehouseTransactions.RemoveRange(_context.WarehouseTransactions.Where(p => p.SectionId == SaleDocument.SectionId && p.CreatorId == id));
                _context.SellDocTransPaymentMappings.RemoveRange(_context.SellDocTransPaymentMappings.Where(p => p.SellDocumentId == id));
                _context.SellDocuments.Remove(SaleDocument);

                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
 public ActionResult EditSellDocument(SellDocument sellDocument)
 {
     db.Entry(sellDocument).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }