public bool Delete(int movieID) { try { using (var DBConnection = new DB()) { var movieToDelete = DBConnection.Movies.Find(movieID); DBConnection.Movies.Remove(movieToDelete); DBConnection.SaveChanges(); Loggings.GeneralLog("Deleted Movie with ID: " + movieID); return(true); } } catch (Exception ex) { var logg = new LoggTypeDAL() { EventType = "Exception", Created_By = "System", LogMessage = ex.ToString(), Created_date = DateTime.Now }; Loggings.LogToBoth(logg); return(false); } }
public MovieModelDAL Get(int movieId) { try { using (var DBConnection = new DB()) { var movieFound = DBConnection.Movies.Find(movieId); if (movieFound == null) { Loggings.GeneralLog("Could not find Movie with ID: " + movieId); return(null); } else { Loggings.GeneralLog("Found Movie with ID: " + movieId); return(movieFound); } } } catch (Exception ex) { var logg = new LoggTypeDAL() { EventType = "Exception", Created_By = "System", LogMessage = ex.ToString(), Created_date = DateTime.Now }; Loggings.LogToBoth(logg); return(null); } }
public bool Delete(string email) { try { using (var DBConnection = new DB()) { var customerToDelete = DBConnection.Customers.Find(email); DBConnection.Customers.Remove(customerToDelete); DBConnection.SaveChanges(); Loggings.GeneralLog("Delted Customer with Email: " + email); return(true); } } catch (Exception ex) { var logg = new LoggTypeDAL() { EventType = "Exception", Created_By = "System", LogMessage = ex.ToString(), Created_date = DateTime.Now }; Loggings.LogToBoth(logg); return(false); } }
public bool Create(CustomerModelDAL customer) { try { using (var DBConnection = new DB()) { DBConnection.Customers.Add(customer); DBConnection.SaveChanges(); Loggings.GeneralLog("Created Customer with Email: " + customer.Email); return(true); } } catch (Exception ex) { var logg = new LoggTypeDAL() { EventType = "Exception", Created_By = "System", LogMessage = ex.ToString(), Created_date = DateTime.Now }; Loggings.LogToBoth(logg); return(false); } }
public CustomerModelDAL Get(string email) { try { using (var DBConnection = new DB()) { var customerFound = DBConnection.Customers.Find(email); if (customerFound == null) { Loggings.GeneralLog("Could not find Customer with Email: " + email); return(null); } else { Loggings.GeneralLog("Found with Email: " + email); return(customerFound); } } } catch (Exception ex) { var logg = new LoggTypeDAL() { EventType = "Exception", Created_By = "System", LogMessage = ex.ToString(), Created_date = DateTime.Now }; Loggings.LogToBoth(logg); return(null); } }
public bool Update(MovieOrderModelDAL movieOrder) { try { using (var DBConnection = new DB()) { var movieOrderFound = DBConnection.MovieOrders.Find(movieOrder.ID); if (movieOrderFound == null) { Loggings.GeneralLog("Could not find Movie Order with ID: " + movieOrder.ID); return(false); } movieOrderFound.RentalStartTimeStamp = movieOrder.RentalStartTimeStamp; movieOrderFound.RentedMovieId = movieOrder.RentedMovieId; DBConnection.SaveChanges(); Loggings.GeneralLog("Updated Movie Order with ID: " + movieOrder.ID); return(true); } } catch (Exception ex) { var logg = new LoggTypeDAL() { EventType = "Exception", Created_By = "System", LogMessage = ex.ToString(), Created_date = DateTime.Now }; Loggings.LogToBoth(logg); return(false); } }
public bool Update(MovieModelDAL movie) { try { using (var DBConnection = new DB()) { var movieFound = DBConnection.Movies.Find(movie.ID); if (movieFound == null) { Loggings.GeneralLog("Could not find Movie with ID: " + movie.ID); return(false); } movieFound.Title = movie.Title; movieFound.Year = movie.Year; movieFound.Rated = movie.Rated; movieFound.Runtime = movie.Runtime; movieFound.Genre = movie.Genre; movieFound.Director = movie.Director; movieFound.Plot = movie.Plot; movieFound.Poster = movie.Poster; movieFound.ImdbRating = movie.ImdbRating; movieFound.ScreenShot = movie.ScreenShot; DBConnection.SaveChanges(); Loggings.GeneralLog("Updated Movie with ID: " + movie.ID); return(true); } } catch (Exception ex) { var logg = new LoggTypeDAL() { EventType = "Exception", Created_By = "System", LogMessage = ex.ToString(), Created_date = DateTime.Now }; Loggings.LogToBoth(logg); return(false); } }
public bool Update(CustomerModelDAL customer) { try { using (var DBConnection = new DB()) { var customerFound = DBConnection.Customers.Find(customer.Email); if (customerFound == null) { Loggings.GeneralLog("Could not find Customer with Email: " + customer.Email); return(false); } customerFound.Email = customer.Email; customerFound.FirstName = customer.FirstName; customerFound.LastName = customer.LastName; if (customerFound.Password != null) { customerFound.Password = customer.Password; } DBConnection.SaveChanges(); Loggings.GeneralLog("Updated Customer with Email: " + customer.Email); return(true); } } catch (Exception ex) { var logg = new LoggTypeDAL() { EventType = "Exception", Created_By = "System", LogMessage = ex.ToString(), Created_date = DateTime.Now }; Loggings.LogToBoth(logg); return(false); } }