public byte SetOrderStatus(int id)
        {
            try
            {
                using (var db = new LunaContext())
                {
                    //Logg event to file
                    db.LogFromDB();

                    var order = db.Orders.FirstOrDefault(i => i.OrderId == id);
                    {
                        if (order.Status == 1)
                        {
                            order.Status = 0;
                            db.SaveChanges();
                        }
                        else
                        {
                            order.Status = 1;
                            db.SaveChanges();
                        }
                    }
                }
                return(1);
            }
            catch (Exception e)
            {
                ErrorLog(e);
                return(0);
            }
        }
        public byte SetUserStatus(string email)
        {
            try
            {
                using (var db = new LunaContext())
                {
                    //Logg event to file
                    db.LogFromDB();

                    var user = db.Users.FirstOrDefault(i => i.Email == email);
                    {
                        if (user.AccountStatus == 1)
                        {
                            user.AccountStatus = 0;
                            db.SaveChanges();
                        }
                        else
                        {
                            user.AccountStatus = 1;
                            db.SaveChanges();
                        }
                    }
                }
                return(1);
            }
            catch (Exception e)
            {
                ErrorLog(e);
                return(0);
            }
        }
        public bool VerifyAdmin(Login login)
        {
            Debug.WriteLine("VERIFY");
            try
            {
                using (var db = new LunaContext())
                {
                    //Logg event to file
                    db.LogFromDB();

                    AdminUser adminUser = db.AdminUsers.FirstOrDefault(u => u.Username == login.Username);
                    if (adminUser != null)
                    {
                        byte[] usedPassword = PasswordEncryption.toHash(login.Password, adminUser.Salt);
                        return(adminUser.Password.SequenceEqual(usedPassword));
                    }
                    else
                    {
                        return(false);
                    }
                }
            } catch (Exception e)
            {
                ErrorLog(e);
                return(false);
            }
        }
        public bool EditMovie(Movie movie)
        {
            try
            {
                using (var db = new LunaContext())
                {
                    //Logg event to file
                    db.LogFromDB();

                    var MovieInDb = db.Movies.First(m => m.MovieId == movie.MovieId);

                    MovieInDb.Title         = movie.Title;
                    MovieInDb.Price         = movie.Price;
                    MovieInDb.ReleaseYear   = movie.ReleaseYear;
                    MovieInDb.ContentRating = movie.ContentRating;
                    MovieInDb.Director      = movie.Director;
                    MovieInDb.Duration      = movie.Duration;
                    MovieInDb.Genre         = movie.Genre;
                    MovieInDb.Storyline     = movie.Storyline;

                    db.SaveChanges();
                    return(true);
                }
            } catch (Exception e)
            {
                ErrorLog(e);
                return(false);
            }
        }
        public bool AddMovie(Movie movie)
        {
            try {
                using (var db = new LunaContext())
                {
                    //Logg event to file
                    db.LogFromDB();

                    if (movie != null)
                    {
                        Movie newMovie = new Movie
                        {
                            Title         = movie.Title,
                            Director      = movie.Director,
                            ContentRating = movie.ContentRating,
                            IsAvailable   = 1,
                            Genre         = movie.Genre,
                            Duration      = movie.Duration,
                            Price         = movie.Price,
                            Storyline     = movie.Storyline,
                            ReleaseYear   = movie.ReleaseYear,
                            Poster        = movie.Poster,
                            Stars         = movie.Stars
                        };

                        db.Movies.Add(newMovie);
                        db.SaveChanges();
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }catch (Exception e)
            {
                ErrorLog(e);
                return(false);
            }
        }
        public bool EditUser(User user)
        {
            try
            {
                using (var db = new LunaContext())
                {
                    //Logg event to file
                    db.LogFromDB();

                    var UserInDb = db.Users.First(u => u.UserId == user.UserId);

                    UserInDb.FirstName = user.FirstName;
                    UserInDb.LastName  = user.LastName;
                    UserInDb.Address   = user.Address;

                    if (db.PostalAddresses.Find(user.PostalAddress.ZipCode) != null)
                    {
                        UserInDb.PostalAddress = db.PostalAddresses.FirstOrDefault(z => z.ZipCode == user.PostalAddress.ZipCode);
                    }
                    else
                    {
                        UserInDb.PostalAddress = new PostalAddress()
                        {
                            ZipCode    = user.PostalAddress.ZipCode,
                            PostalArea = user.PostalAddress.PostalArea
                        };
                    }
                    //UserInDb.PostalAddress.PostalArea = user.PostalAddress.PostalArea;
                    //UserInDb.PostalAddress.ZipCode = user.PostalAddress.ZipCode;

                    db.SaveChanges();
                    return(true);
                }
            } catch (Exception e)
            {
                ErrorLog(e);
                return(false);
            }
        }