private void _saveImage(Image img) { try { if (!_imageAlreadyExists(img)) { Logger.Debug("Saving new " + img.ImagePath + " to Context"); _contextObs.Add(img); Logger.Debug(".. Saved to Context"); imageImportCounter++; } else { Image exImg = _getExistingImage(img); if (exImg != null) { _updateImageProperties(img, ref exImg); _contextObs.Update(exImg); imageUpdateCounter++; Logger.Debug($"{img.ImagePath} updated"); } } } catch (Exception e) { Logger.Error(e.InnerException, "Error Adding Image to Context"); } }
public async Task <IActionResult> Edit(int id, [Bind("ID,Slicer,Printer,Estimate,Actual")] Observation observation) { if (id != observation.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(observation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ObservationExists(observation.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(observation)); }