public async Task <ActionResult> Edit([Bind(Include = "SerialNumber,LastCheckin,CreationDate,Managed,Storage,Deleted,Name,Model,MACAddress,IpAddress")] DBAsset dBAsset) { if (ModelState.IsValid) { db.Entry(dBAsset).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(dBAsset)); }
// GET: DBAssets/Details/5 public async Task <ActionResult> Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DBAsset dBAsset = await db.DBAssets.FindAsync(id); if (dBAsset == null) { return(HttpNotFound()); } return(View(dBAsset)); }
public void CheckIn(Asset asset) { if (asset.SerialNumber == "" || asset.SerialNumber == null) { return; } using (DBAssetModel ctx = new DBAssetModel()) { var _dbAsset = ctx.DBAssets.Find(asset.SerialNumber); if (_dbAsset == null) { var dbAsset = new DBAsset(asset); dbAsset.Create(); return; } if (_dbAsset.Deleted == true) { _dbAsset.Deleted = false; } if (_dbAsset.Storage == true) { _dbAsset.Storage = false; } if (_dbAsset.Name != asset.Name) { _dbAsset.Name = asset.Name; } if (_dbAsset.IpAddress != asset.IpAddress) { _dbAsset.IpAddress = asset.IpAddress; } _dbAsset.LastCheckin = DateTime.Now; ctx.SaveChanges(); } }