public ActionResult AddLabelPrinter(string urlReturn) { PrintLabelModel model = new PrintLabelModel { UrlReturn = urlReturn }; ViewBag.Title = "Add Label Printer"; return View("LabelPrinterEdit", model); }
public ActionResult AddLabelPrinter(PrintLabelModel model) { if (ModelState.IsValid) { LabelPrinter printer = Mapper.Map<PrintLabelModel, LabelPrinter>(model); PrdnDBContext.LabelPrinters.AddObject(printer); PrdnDBContext.SaveChanges(); return RedirectToAction(actionName: "LabelPrinters"); } ViewBag.Title = "Add Label Printer"; return View("LabelPrinterEdit", model); }
public ActionResult EditLabelPrinter(PrintLabelModel model) { if (ModelState.IsValid) { LabelPrinter printer = (from x in PrdnDBContext.LabelPrinters where x.ID == model.ID select x).FirstOrDefault(); if (printer == null) { return ErrMsgView("Sorry - Invalid printer ID " + model.ID.ToString()); } Mapper.Map(model, printer); PrdnDBContext.SaveChanges(); return RedirectToAction(actionName: "LabelPrinters"); } ViewBag.Title = "Edit Label Printer"; return View("LabelPrinterEdit", model); }