public IActionResult GetModel(string printerName) { var model = new CartridgeViewModel(); var printModel = _printerRepository.GetAllPrinters().Where(o => o.Printer_Name == printerName) .Select(o => o.Printer_Model).FirstOrDefault(); return(Json(printModel)); }
public IActionResult CartridgeIssue() { var model = new CartridgeViewModel(); model.PrinterIdReturn = _printerRepository.GetAllPrinters() .Select(o => new SelectListItem(o.Printer_Name, o.Printer_Name)); return(View(model)); }
public IActionResult CartridgeAdd(CartridgeViewModel newcartridge) { Cartridge currentCartridge = new Cartridge(); newcartridge.Printer_Model = _printerRepository.GetAllPrinters() .Where(o => o.Printer_Name == newcartridge.Printer_Recd_For).Select(o => o.Printer_Model) .FirstOrDefault(); newcartridge.Date_Keyed = DateTime.Now; currentCartridge.Cartridge_Number = newcartridge.Cartridge_Number; currentCartridge.Printer_Model = newcartridge.Printer_Model; currentCartridge.Cartridge_Type = newcartridge.Cartridge_Type; currentCartridge.Printer_Recd_For = newcartridge.Printer_Recd_For; currentCartridge.Date_Keyed = newcartridge.Date_Keyed; _cartridgeRepository.Add(currentCartridge); ModelState.Clear(); return(RedirectToAction("CartridgeAdd", "Cartridge")); }
public ActionResult DeleteCartridge(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var viewModel = new CartridgeViewModel(); var entity = this.cartridgeService.FindById((int)id) as Cartridge; var entityView = this.cartridgeViews.Where(cv => cv.Id == id).First(); viewModel.Entity = entity; viewModel.EntityView = entityView; if (entity == null) { return(HttpNotFound()); } return(View(viewModel)); }