예제 #1
0
        public ActionResult AddMovie(AddMoviesModel _addMovie)
        {
            using (SinemaSitesiEntities db = new SinemaSitesiEntities())
            {
                Movie x = new Movie();
                x.Name      = _addMovie.Name;
                x.Price     = _addMovie.Price;
                x.Year      = _addMovie.Year;
                x.Detail    = _addMovie.Detail;
                x.AddedDate = DateTime.Now;
                db.Movie.Add(x);
                db.SaveChanges();

                _addMovie.ID = db.Movie.OrderByDescending(t => t.ID).Select(t => t.ID).First();


                MovieCategory y = new MovieCategory();
                foreach (var item in _addMovie.CategoryIDs)
                {
                    y.MovieID    = _addMovie.ID;
                    y.CategoryID = item;
                }
                db.MovieCategory.Add(y);
                db.SaveChanges();
            }
            return(RedirectToAction("Movies", "Admin"));
        }
예제 #2
0
        public ActionResult EditCategory(AdminCategoryModel _editCategory)
        {
            string let = Request.Url.PathAndQuery;

            string[] parcalar = let.Split('=');
            _editCategory.ID = Convert.ToInt32(parcalar[1]);

            using (SinemaSitesiEntities db = new SinemaSitesiEntities())
            {
                var isThere = db.Category.Where(x => x.Name == _editCategory.Name).FirstOrDefault();
                if (isThere != null)
                {
                    ViewBag.Error = "HATA! Bu kategori ismi kayıtlarda var.Lütfen başka bir giriş yapınız.";
                    ModelState.AddModelError("", "HATA! Bu kategori ismi kayıtlarda var.Lütfen başka bir giriş yapınız.");

                    return(View(_editCategory));
                }
                else
                {
                    var data = db.Category.Find(_editCategory.ID);
                    data.Name = _editCategory.Name;

                    db.SaveChanges();
                }
            }

            return(RedirectToAction("Categories", "Admin"));
        }
예제 #3
0
        public ActionResult Register(RegisterModel registerUser)
        {
            using (SinemaSitesiEntities db = new SinemaSitesiEntities())
            {
                var isThere = db.Member.First(x => x.Email == registerUser.Email || x.UserName == registerUser.UserName);
                if (isThere != null)
                {
                    ViewBag.Error = "HATA! Daha önce kayıt olmuş kullanıcı adı ya da şifre";
                    return(RedirectToAction("Register"));
                }
                else if (registerUser.Password != registerUser.PasswordAgain)
                {
                    ViewBag.Error = "Girilen şifreler aynı değil";
                    return(RedirectToAction("Register"));
                }
                else
                {
                    Member member = new Member();
                    member.Address  = registerUser.Address;
                    member.Email    = registerUser.Email;
                    member.IsAdmin  = false;
                    member.Name     = registerUser.Name;
                    member.Password = registerUser.Password;
                    member.Phone    = registerUser.Phone;
                    member.UserName = registerUser.UserName;
                    member.Surname  = registerUser.Surname;

                    db.Member.Add(member);
                    db.SaveChanges();
                    return(RedirectToAction("Login", "User"));
                }
            }
        }
예제 #4
0
        public ActionResult HomePageCategories(AdminHPCategoryModel model)
        {
            using (SinemaSitesiEntities db = new SinemaSitesiEntities())
            {
                var data1 = db.Category.ToList();
                foreach (var item in data1)
                {
                    item.IsHomePage = false;
                    db.SaveChanges();
                }

                foreach (var item in model.Ids)
                {
                    var data = db.Category.Find(item);
                    data.IsHomePage = true;
                    db.SaveChanges();
                }
            }
            return(RedirectToAction("Index", "Admin"));
        }
예제 #5
0
        public ActionResult DeletePicture()
        {
            string let = Request.Url.PathAndQuery;

            string[] parcalar = let.Split('=');
            int      _ID      = Convert.ToInt32(parcalar[1]);

            using (SinemaSitesiEntities db = new SinemaSitesiEntities())
            {
                var data = db.Picture.Where(x => x.ID == _ID).FirstOrDefault();
                db.Picture.Remove(data);
                db.SaveChanges();
                return(RedirectToAction("Detail", "Picture", new { ID = data.MovieID }));
            }
        }
예제 #6
0
        public ActionResult UnMaskMovie()
        {
            string let = Request.Url.PathAndQuery;

            string[] parcalar       = let.Split('=');
            int      _maskedMovieID = Convert.ToInt32(parcalar[1]);

            using (SinemaSitesiEntities db = new SinemaSitesiEntities())
            {
                var data = db.Movie.Find(_maskedMovieID);
                data.IsMasked = false;

                db.SaveChanges();
            }
            return(RedirectToAction("Movies", "Admin"));
        }
예제 #7
0
        public ActionResult UserProfile(RegisterModel _user)
        {
            _user.UserName = Session["UserName"].ToString();

            using (SinemaSitesiEntities db = new SinemaSitesiEntities())
            {
                Member member = db.Member.Where(x => x.UserName == _user.UserName).First();
                member.Address = _user.Address;
                member.Phone   = _user.Phone;
                member.Name    = _user.Name;
                member.Surname = _user.Surname;

                db.SaveChanges();
            }

            return(RedirectToAction("Home", "Home"));
        }
예제 #8
0
        public ActionResult DeleteComment(int?_deleteCommentID)
        {
            string let = Request.Url.PathAndQuery;

            string[] parcalar = let.Split('=');
            _deleteCommentID = Convert.ToInt32(parcalar[1]);



            using (SinemaSitesiEntities db = new SinemaSitesiEntities())
            {
                var data = db.Comment.Where(x => x.ID == _deleteCommentID).First();
                db.Comment.Remove(data);
                db.SaveChanges();
            }
            return(RedirectToAction("Comments", "Admin"));
        }
예제 #9
0
        public ActionResult AddPicture(MoviePicture _moviePicture)
        {
            string let = Request.Url.PathAndQuery;

            string[] parcalar = let.Split('=');
            int      _movieID = Convert.ToInt32(parcalar[1]);

            using (SinemaSitesiEntities db = new SinemaSitesiEntities())
            {
                Picture p = new Picture();
                p.MovieID         = _movieID;
                p.PictureLocation = "\\Assets\\Pictures\\" + _moviePicture.PictureLocation;

                db.Picture.Add(p);
                db.SaveChanges();
            }

            return(RedirectToAction("Detail", "Picture", new { ID = _movieID }));
        }
예제 #10
0
 public ActionResult AddCategory(AdminCategoryModel _category)
 {
     using (SinemaSitesiEntities db = new SinemaSitesiEntities())
     {
         var isThere = db.Category.Where(x => x.Name == _category.Name).FirstOrDefault();
         if (isThere != null)
         {
             ViewBag.Error = "HATA! Bu kategori ismi kayıtlarda var.Lütfen başka bir giriş yapınız.";
             ModelState.AddModelError("", "HATA! Bu kategori ismi kayıtlarda var.Lütfen başka bir giriş yapınız.");
             return(View());
         }
         else
         {
             Category c = new Category();
             c.Name = _category.Name;
             db.Category.Add(c);
             db.SaveChanges();
             return(RedirectToAction("Categories", "Admin"));
         }
     }
 }
예제 #11
0
        public ActionResult EditMovie(EditMoviesModel _editMovie)
        {
            string let = Request.Url.PathAndQuery;

            if (let.Contains('='))
            {
                string[] parcalar = let.Split('=');
                _editMovie.ID = Convert.ToInt32(parcalar[1]);
            }
            using (SinemaSitesiEntities db = new SinemaSitesiEntities())
            {
                var data = db.Movie.Find(_editMovie.ID);
                data.Name   = _editMovie.Name;
                data.Price  = _editMovie.Price;
                data.Year   = _editMovie.Year;
                data.Detail = _editMovie.Detail;

                db.SaveChanges();
            }
            return(RedirectToAction("Movies", "Admin"));
        }
예제 #12
0
        public ActionResult ChangePassword(PasswordModel password)
        {
            if (password.Password == password.PasswordAgain)
            {
                using (SinemaSitesiEntities db = new SinemaSitesiEntities())
                {
                    Member member = db.Member.Where(x => x.UserName == Session["UserName"].ToString()).FirstOrDefault();
                    member.Password = password.Password;
                    db.SaveChanges();
                    return(RedirectToAction("Home", "Home"));
                }
            }
            else
            {
                using (SinemaSitesiEntities db = new SinemaSitesiEntities())
                {
                    var data = db.Member.Where(x => x.UserName == Session["UserName"].ToString()).FirstOrDefault();

                    ModelState.AddModelError("", "Hatalı giriş yaptınız. Tekrar deneyin");
                    return(View(data));
                }
            }
        }