Exemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "SalesInvoiceId,CustomerId,BranchId,SalesType,UserId,DateSold")] SalesInvoice salesInvoice)
 {
     if (ModelState.IsValid)
     {
         _salesInvoiceService.EditSalesInvoice(salesInvoice);
         return(RedirectToAction("Index"));
     }
     return(View(salesInvoice));
 }
Exemplo n.º 2
0
        public ActionResult AddLineItem([Bind(Include = "SalesInvoiceId,Quantity,ProductId")] SalesInvoiceLineItemViewModel salesInvoiceLineItemViewModel)
        {
            var salesInvoice = _salesInvoiceService.Get(t => t.SalesInvoiceId == salesInvoiceLineItemViewModel.SalesInvoiceId, null, "SalesLineItems").FirstOrDefault();
            int exists       = salesInvoice.SalesLineItems.Where(t => t.ProductId == salesInvoiceLineItemViewModel.ProductId).ToList().Count;

            if (exists > 0)
            {
                return(RedirectToAction("Create", "SalesInvoices", new { id = salesInvoice.SalesInvoiceId }));
            }
            var salesInvoiceLineItem = new SalesLineItem()
            {
                ProductId      = salesInvoiceLineItemViewModel.ProductId,
                Quantity       = salesInvoiceLineItemViewModel.Quantity,
                SalesInvoiceId = salesInvoiceLineItemViewModel.SalesInvoiceId,
                UnitPrice      = _productService.FindById(salesInvoiceLineItemViewModel.ProductId).UnitPrice
            };

            salesInvoice.SalesLineItems.Add(salesInvoiceLineItem);
            _salesInvoiceService.EditSalesInvoice(salesInvoice);
            return(RedirectToAction("Create", "SalesInvoices", new { id = salesInvoice.SalesInvoiceId }));
        }