예제 #1
0
 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);
     }
 }
예제 #2
0
 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);
     }
 }
예제 #3
0
        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);
            }
        }
예제 #4
0
 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);
     }
 }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        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);
            }
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
        /// <summary>
        /// This is a method for finding customer with matching credentials.
        /// </summary>
        /// <param name="userName">The username of the customer</param>
        /// <param name="hashedPassword">The hashed password of the customer</param>
        /// <returns>
        /// 1. Returns true if an entry is found with the specified credentials.
        /// 2. Return false if an entry is not found with the specified credentials.
        /// </returns>
        public bool FindCustomerMatchingCredentials(string userName, byte[] hashedPassword)
        {
            try
            {
                using (var DBConnection = new DB())
                {
                    var result = DBConnection.Customers.Find(userName);

                    if (result == null)
                    {
                        return(false);
                    }
                    else
                    {
                        if (result.Password.SequenceEqual(hashedPassword))
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var logg = new LoggTypeDAL()
                {
                    EventType    = "Exception",
                    Created_By   = "System",
                    LogMessage   = ex.ToString(),
                    Created_date = DateTime.Now
                };
                Loggings.LogToBoth(logg);
                return(false);
            }
        }
예제 #10
0
 public List <MovieModelDAL> GetAllMoviesWithTitleMatchingSearchText(string searchText)
 {
     try
     {
         using (var DBConnection = new DB())
         {
             var movies = DBConnection.Movies.Where(m => m.Title.Contains(searchText)).ToList();
             return(movies);
         }
     }
     catch (Exception ex)
     {
         var logg = new LoggTypeDAL()
         {
             EventType    = "Exception",
             Created_By   = "System",
             LogMessage   = ex.ToString(),
             Created_date = DateTime.Now
         };
         Loggings.LogToBoth(logg);
         return(null);
     }
 }
예제 #11
0
 public async Task <List <MovieModelDAL> > GetAll(bool seedNeeded)
 {
     try
     {
         using (var DBConnection = new DB(seedNeeded))
         {
             var allMovies = DBConnection.Movies.ToList();
             return(allMovies);
         }
     }
     catch (Exception ex)
     {
         var logg = new LoggTypeDAL()
         {
             EventType    = "Exception",
             Created_By   = "System",
             LogMessage   = ex.ToString(),
             Created_date = DateTime.Now
         };
         Loggings.LogToBoth(logg);
         return(null);
     }
 }
예제 #12
0
 public List <CustomerModelDAL> GetAll()
 {
     try
     {
         using (var DBConnection = new DB())
         {
             var allCustomers = DBConnection.Customers.ToList();
             return(allCustomers);
         }
     }
     catch (Exception ex)
     {
         var logg = new LoggTypeDAL()
         {
             EventType    = "Exception",
             Created_By   = "System",
             LogMessage   = ex.ToString(),
             Created_date = DateTime.Now
         };
         Loggings.LogToBoth(logg);
         return(null);
     }
 }
예제 #13
0
 public List <MovieOrderModelDAL> GetUserMovies(string userEmail)
 {
     try
     {
         using (var DBConnection = new DB())
         {
             var orderedMovies = DBConnection.MovieOrders.Where(movieRental => movieRental.Email == userEmail).ToList();
             return(orderedMovies);
         }
     }
     catch (Exception ex)
     {
         var logg = new LoggTypeDAL()
         {
             EventType    = "Exception",
             Created_By   = "System",
             LogMessage   = ex.ToString(),
             Created_date = DateTime.Now
         };
         Loggings.LogToBoth(logg);
         return(null);
     }
 }