Beispiel #1
0
        public ActionResult CreateInvoice(InvoiceModel model)
        {
            if (ModelState.IsValid)
            {
                bool invoiceFound = InvoiceProcessor.LoadInvoices().Any(invoice => invoice.InvoiceId == model.InvoiceId && invoice.LocationId == model.LocationId);

                if (invoiceFound)
                {
                    return(View());
                }

                InvoiceProcessor.CreateInvoice(
                    model.InvoiceId,
                    model.LocationId,
                    model.InvoiceNumber,
                    model.Date,
                    model.ClientName
                    );

                InvoiceProcessor.CreateInvoiceDetail(
                    model.InvoiceDetailsId,
                    model.InvoiceId,
                    model.LocationId,
                    model.ProductName,
                    model.Quantity,
                    model.Price,
                    model.Value
                    );

                return(RedirectToAction("ViewInvoices"));
            }

            return(View());
        }
Beispiel #2
0
        public ActionResult UpdateInvoice(int invoiceId, int locationId)
        {
            var  invoices        = InvoiceProcessor.LoadInvoices();
            var  invoicesDetails = InvoiceProcessor.LoadInvoiceDetails();
            bool invoiceFound    = invoices.Any(invoice => invoice.InvoiceId == invoiceId && invoice.LocationId == locationId);

            if (!invoiceFound)
            {
                return(HttpNotFound());
            }

            var invoiceData        = invoices.SingleOrDefault(invoice => invoice.InvoiceId == invoiceId && invoice.LocationId == locationId);
            var invoiceDetailsData = invoicesDetails.SingleOrDefault(invoiceDetails => invoiceDetails.InvoiceId == invoiceId && invoiceDetails.LocationId == locationId);

            InvoiceModel invoiceToUpdate = new InvoiceModel
            {
                InvoiceId        = invoiceId,
                LocationId       = locationId,
                InvoiceNumber    = invoiceData.InvoiceNumber,
                Date             = invoiceData.Date,
                ClientName       = invoiceData.ClientName,
                InvoiceDetailsId = invoiceDetailsData.InvoiceDetailsId,
                ProductName      = invoiceDetailsData.ProductName,
                Price            = invoiceDetailsData.Price,
                Quantity         = invoiceDetailsData.Quantity
            };

            return(View(invoiceToUpdate));
        }
Beispiel #3
0
        private async Task LoadFromServerToGrid()
        {
            await CompanyProcessor.LoadCompanies();

            await RepresentativeProcessor.LoadRepresentatives();

            await InvoiceProcessor.LoadInvoices();
        }
Beispiel #4
0
        public ActionResult ViewInvoices()
        {
            ViewBag.Message = "Invoices";

            var data = InvoiceProcessor.LoadInvoices();
            List <InvoiceModel> invoices = new List <InvoiceModel>();

            foreach (var row in data)
            {
                invoices.Add(new InvoiceModel
                {
                    InvoiceId     = row.InvoiceId,
                    LocationId    = row.LocationId,
                    InvoiceNumber = row.InvoiceNumber,
                    ClientName    = row.ClientName,
                    Date          = row.Date
                });
            }

            return(View(invoices));
        }