Esempio n. 1
0
        public ActionResult Create(Payment payment)
        {
            if (ModelState.IsValid)
            {
                db.Payments.Add(payment);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.CorporateAccountID = new SelectList(db.CorporateAccounts, "CorporateAccountID", "Title", payment.CorporateAccountID);
            ViewBag.RequestIssueID = new SelectList(db.RequestIssues, "RequestIssueID", "DetailedDescription", payment.RequestIssueID);
            return View(payment);
        }
Esempio n. 2
0
        public ActionResult CreateCustomex(PaymentViewModel viewModel)
        {
            var payment_ = new Payment
            {
                BudgetNum = viewModel.BudgetNum,
                PurchaseNum = viewModel.PurchaseNum,
                CorporateAccountID = viewModel.CorporateAccountID,
                InvoiceDate = viewModel.InvoiceDate,
                InvoiceNum = viewModel.InvoiceNum,
                InvoiceTotal = viewModel.InvoiceTotal,
                PaymentDate = viewModel.PaymentDate,
                RequestIssueID = viewModel.RequestIssueID,
                Description = viewModel.Description
            };

            db.Payments.Add(payment_);
            db.SaveChanges();

            int _paymentid = payment_.PaymentID;
            int i = 0;
            foreach (var file_ in Request.Files)
            {
                PaymentFile file = RetrieveFileFromRequest(i);

                if (file.PaymentFileName != null
                    && !db.PaymentFiles.Any(f => f.PaymentFileName.Equals(file.PaymentFileName))
                    && file.PaymentFileSize > 0)
                {
                    file.Payment = payment_;
                    db.PaymentFiles.Add(file);
                    db.SaveChanges();
                }
                i++;
            }
            // save product
            // var product = new Product { Name = viewModel.Name, Price = viewModel.Price });
            // repo.Save(product);

            // now do something with the files
            //foreach (var file in viewModel.PaymentFiles)
            //{
            //    if (file.PaymentFileSize > 0)
            //    {
            //        var fileName = Path.GetFileName(file.PaymentFileName);
            //        var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
            //        file.SaveAs(path);
            //    }
            //}
            return RedirectToAction("Index");
        }