public ActionResult Create(HttpPostedFileBase upload, [Bind(Include = "RdInvoiceId,RdId,RdInvoiceDate")] RdInvoice rdInvoice) { if (ModelState.IsValid) { db.RdInvoices.Add(rdInvoice); db.SaveChanges(); //Insert data into RdProduct Table from CSV file. RdProduct product = new RdProduct(); var invoId = (from cust in db.RdInvoices select cust).OrderByDescending(m => m.RdInvoiceId).First(); StreamReader csvreader = new StreamReader(upload.InputStream); while (!csvreader.EndOfStream) { var line = csvreader.ReadLine(); var values = line.Split(','); product.RdInvoiceId = invoId.RdInvoiceId; product.ModelName = values[0].ToString(); product.EmiNo = values[1].ToString(); db.RdProducts.Add(product); db.SaveChanges(); } return(RedirectToAction("Index")); } ViewBag.RdId = new SelectList(db.Rds, "RdId", "RdId", rdInvoice.RdId); return(View(rdInvoice)); }
public ActionResult DeleteConfirmed(int id) { RdInvoice rdInvoice = db.RdInvoices.Find(id); db.RdInvoices.Remove(rdInvoice); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "RdInvoiceId,RdId,RdInvoiceDate")] RdInvoice rdInvoice) { if (ModelState.IsValid) { db.Entry(rdInvoice).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RdId = new SelectList(db.Rds, "RdId", "RdId", rdInvoice.RdId); return(View(rdInvoice)); }
// GET: RdInvoices/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RdInvoice rdInvoice = db.RdInvoices.Find(id); if (rdInvoice == null) { return(HttpNotFound()); } return(View(rdInvoice)); }
// GET: RdInvoices/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RdInvoice rdInvoice = db.RdInvoices.Find(id); if (rdInvoice == null) { return(HttpNotFound()); } ViewBag.RdId = new SelectList(db.Rds, "RdId", "RdId", rdInvoice.RdId); return(View(rdInvoice)); }