public ActionResult Edit(int id, [Bind(Include = "InstrumentName,Name,Date,Comment,MaintenanceNeeded")] CheckOuts instrument) { CheckOuts inst2 = db.CheckOuts.Find(id); inst2.InstrumentName = instrument.InstrumentName; inst2.Name = instrument.Name; inst2.Date = instrument.Date; inst2.Comment = instrument.Comment; if (ModelState.IsValid) { db.Entry(inst2).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(instrument)); //if (ModelState.IsValid) //{ // db.Entry(instrument).State = EntityState.Modified; // db.SaveChanges(); // return RedirectToAction("Index"); //} //return View(instrument); }
public void CheckOutItem(int assetId, int libraryCardId) { if (IsCheckedOut(assetId)) { return; // Add logic herer to handle feedback to the user. } var item = _context.LibraryAssets.FirstOrDefault(a => a.Id == assetId); UpdateAssetStatus(assetId, "Checked Out"); var libraryCard = _context.LibraryCards.Include(card => card.CheckOuts).FirstOrDefault(card => card.Id == libraryCardId); var now = DateTime.Now; var checkout = new CheckOuts { LibraryAsset = item, LibraryCard = libraryCard, Since = now, Until = GetDefaultCheckoutTime(now) }; _context.Add(checkout); var checkoutHistory = new CheckOutHistory { CheckedOut = now, LibraryAsset = item, LibraryCard = libraryCard, }; _context.Add(checkoutHistory); _context.SaveChanges(); }
public ActionResult Create([Bind(Include = "InstrumentName,Name,Date,Comment,ID,MaintenanceNeeded")] CheckOuts instrument) { instrument.IsCheckedOut = true; if (ModelState.IsValid) { db.CheckOuts.Add(instrument); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(instrument)); }
// GET: CheckOuts/Edit/5 public ActionResult Edit(int id) { /* if (id == null) * { * return new HttpStatusCodeResult(HttpStatusCode.BadRequest); * }*/ CheckOuts instrument = db.CheckOuts.Find(id); if (instrument == null) { return(HttpNotFound()); } return(View(instrument)); }
// GET: CheckOuts/Details/5 public ActionResult Details(int id) { //if (id == null) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} CheckOuts instrument = db.CheckOuts.Find(id); if (instrument == null) { return(HttpNotFound()); } return(View(instrument)); }
public ActionResult DeleteConfirmed(int id, [Bind(Include = "DateIn,CommentIn,MaintenanceNeeded")] CheckOuts instrument) { CheckOuts inst2 = db.CheckOuts.Find(id); inst2.DateIn = instrument.DateIn; inst2.CommentIn = instrument.CommentIn; inst2.IsCheckedOut = false; if (ModelState.IsValid) { db.Entry(inst2).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(instrument)); }
public void CheckOutItem(int assetId, int LibraryCardId) { if (IscheckedOut(assetId)) { return; } var item = _context.LibraryAssets .FirstOrDefault(a => a.Id == assetId); UpdateAssetStatus(assetId, "Checked Out"); var librarycard = _context.LibraryCards .Include(c => c.CheckOuts) .FirstOrDefault(c => c.Id == LibraryCardId); var now = DateTime.Now; var checkout = new CheckOuts { LibraryAsset = item, LibraryCard = librarycard, Since = now, Until = GetdefaultCheckoutTime(now) }; _context.Add(checkout); var chechouthistory = new CheckOutHistory { CheckedOut = now, LibraryAsset = item, LibraryCard = librarycard, }; _context.Add(chechouthistory); _context.SaveChanges(); }
public Task <bool> ParseLine(string line) { var tokens = GetTokens(line); LogEvents tokenType; return(Task.Run(() => { ProgressInt += progressInc; if (tokens.Any() && Enum.TryParse(tokens[0], out tokenType)) { switch (tokenType) { case LogEvents.PRODUCT: return Products.TryAdd(ParseProduct(tokens)); case LogEvents.IN: return CheckIns.TryAdd(ParseCheckIn(tokens)); case LogEvents.OUT: return CheckOuts.TryAdd(ParseCheckOut(tokens)); case LogEvents.DENY: return Denys.TryAdd(ParseDeny(tokens)); case LogEvents.SHUTDOWN: return Shutdowns.TryAdd(ParseShutdown(tokens)); case LogEvents.END: return ParseEnd(tokens); default: return false; } } return false; })); }
public void Add(CheckOuts newcheckOuts) { _context.Add(newcheckOuts); _context.SaveChanges(); }
public void Add(CheckOuts newCheckout) { _context.Add(newCheckout); _context.SaveChanges(); }