/// <summary>
        /// Find matching PO number from database
        /// </summary>
        /// <param name="PONumber">a string parameter</param>
        /// <returns>return a model</returns>
        public POViwerModel GetPODocument(string PONumber)
        {
            POViwerModel po = _db.InvoiceDocuments
                              .Where(w => w.invoice_PO == PONumber)
                              .Select(x => new POViwerModel
            {
                PONumber        = x.invoice_PO,
                InvoiceID       = x.invoice_id,
                InvoiceMIME     = x.invoice_MIME,
                InvoiceDocument = x.invoice_document,
            }).FirstOrDefault();

            return(po);
        }
Beispiel #2
0
        public ActionResult Index(POViwerModel model)
        {
            if (ModelState.IsValid)
            {
                POViewerServices PSvc = new POViewerServices();
                model = PSvc.GetPODocument(model.PONumber);

                if (model == null)
                {
                    ModelState.AddModelError("PONumber", "Purchase order not found or matched");
                    return(View("Index", model));
                }
            }
            return(View("Index", model));
        }
Beispiel #3
0
        /// <summary>
        /// Get purchase order
        /// </summary>
        /// <param name="PONumber">a string parameter</param>
        /// <returns>return purchase order file</returns>
        public ActionResult GetPOFile(string PONumber)
        {
            POViwerModel POViewModel = new POViwerModel();

            try
            {
                POViewerServices PSvc = new POViewerServices();
                POViewModel = PSvc.GetPODocument(PONumber);

                if (POViewModel.InvoiceDocument.Length > 0)
                {
                    return(File(POViewModel.InvoiceDocument, POViewModel.InvoiceMIME));
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
            return(View("Index", POViewModel));
        }