public bool AddPhoto(Photo photo, Logger logger) { bool result = false; try { using (var db = new PhotoBoothContext()) { if (photo.Created == DateTime.MinValue) { photo.Created = DateTime.Now; } db.Photos.Add(photo); db.SaveChanges(); } result = true; //logger.Info("Record for file {0} created", photo.LocalPathToImage); } catch (Exception ex) { logger.Error("Record for file {0} NOT created!", photo.LocalPathToImage); logger.Error(ex); if (ex.InnerException != null) { logger.Error(ex.InnerException); if (ex.InnerException.InnerException != null) { logger.Error(ex.InnerException.InnerException); } } } return(result); }
public bool SetBoothAvailable() { bool result = false; try { if (IsDatabaseConnectionExist()) { using (var db = new PhotoBoothContext()) { var currentPhotoBooth = db.PhotoBooths.FirstOrDefault(pb => pb.Id == _boothGuid); if (currentPhotoBooth != null) { currentPhotoBooth.LastAvailableDate = DateTime.Now; } db.SaveChanges(); result = true; LogManager.GetLogger("BoothAvailabilityLogger").Info("Availability time updated"); } } } catch (Exception ex) { LogManager.GetLogger("BoothAvailabilityLogger").Error(ex); } return(result); }
public void RemovePrintQueueElement(PrintQueue photoBoothPrintElement) { if (IsDatabaseConnectionExist()) { using (var db = new PhotoBoothContext()) { try { PrintQueue objectToDelete = db.PrintQueue.FirstOrDefault(p => p.BlobPathToImage == photoBoothPrintElement.BlobPathToImage); db.PrintQueue.Remove(objectToDelete); db.SaveChanges(); } catch (Exception ex) { LogManager.GetLogger("PrintTask").Error(ex); } } } }