Beispiel #1
0
 // GET: Admin/Equipments/Create
 public IActionResult Create()
 {
     Middleware.CheckStafLogin(HttpContext);
     ViewData["Equipment_Level_ID"] = new SelectList(_context.Category_Equipment, "ID", "Name");
     ViewData["Room_ID"]            = new SelectList(_context.Rooms, "ID", "Name");
     return(View());
 }
Beispiel #2
0
 public async Task <IActionResult> Edit([Bind("ID,Name,Capacity,Length,Width,Status,Cinema_ID")] Room room)
 {
     Middleware.CheckStafLogin(HttpContext);
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(room);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!RoomExists(room.ID))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(RedirectToAction(nameof(Index)));
 }
Beispiel #3
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Start_Show,Status,Room_ID,Movie_ID")] Movie_Show movie_Show)
        {
            Middleware.CheckStafLogin(HttpContext);
            var room = _context.Rooms.Where(m => m.ID.Equals(movie_Show.Room_ID)).First();

            if (id != movie_Show.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(movie_Show);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Movie_ShowExists(movie_Show.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(Redirect("/Admin/Movie_Show?idCinema=" + room.Cinema_ID + "&date=" + movie_Show.Start_Show.Date));
            }
            ViewData["Movie_ID"] = new SelectList(_context.Movies, "ID", "Directors", movie_Show.Movie_ID);
            ViewData["Room_ID"]  = new SelectList(_context.Rooms, "ID", "Name", movie_Show.Room_ID);
            return(View(movie_Show));
        }
Beispiel #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Row_ID,Col_ID,Status,Room_ID,Equipment_Level_ID")] Equipment equipment)
        {
            Middleware.CheckStafLogin(HttpContext);
            if (id != equipment.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(equipment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EquipmentExists(equipment.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(Redirect("/Admin/Equipments/Index/" + equipment.Room_ID));
            }
            ViewData["Equipment_Level_ID"] = new SelectList(_context.Category_Equipment, "ID", "Name", equipment.Equipment_Level_ID);
            ViewData["Room_ID"]            = new SelectList(_context.Rooms, "ID", "Name", equipment.Room_ID);
            return(View(equipment));
        }
 public async Task <IActionResult> Edit([Bind("ID,Name,Address,Hotline,Status,Manager_ID")] Cinema cinema)
 {
     Middleware.CheckStafLogin(HttpContext);
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(cinema);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!CinemaExists(cinema.ID))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(RedirectToAction(nameof(Index)));
 }
Beispiel #6
0
        public async Task <IActionResult> Index(int status = 1)
        {
            Middleware.CheckStafLogin(HttpContext);
            var dPContext = _context.Customers.Where(c => c.Status == status);

            ViewBag.ListCustomer = await dPContext.ToListAsync();

            return(View());
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            Middleware.CheckStafLogin(HttpContext);
            var category_Equipment = await _context.Category_Equipment.FindAsync(id);

            _context.Category_Equipment.Remove(category_Equipment);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Beispiel #8
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            Middleware.CheckStafLogin(HttpContext);
            var movie_Show = await _context.Movie_Shows.Include(m => m.Room).Where(m => m.ID.Equals(id)).FirstOrDefaultAsync();

            _context.Movie_Shows.Remove(movie_Show);
            await _context.SaveChangesAsync();

            return(Redirect("/Admin/Movie_Show?idCinema=" + movie_Show.Room.Cinema_ID));
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            Middleware.CheckStafLogin(HttpContext);
            var movie = await _context.Movies.FindAsync(id);

            _context.Movies.Remove(movie);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Beispiel #10
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            Middleware.CheckStafLogin(HttpContext);
            var equipment = await _context.Equipments.FindAsync(id);

            _context.Equipments.Remove(equipment);
            await _context.SaveChangesAsync();

            return(Redirect("/Admin/Equipments/Index/" + equipment.Room_ID));
        }
Beispiel #11
0
 public async Task <IActionResult> Create([Bind("ID,Name,Row_ID,Col_ID,Status,Room_ID,Equipment_Level_ID")] Equipment equipment)
 {
     Middleware.CheckStafLogin(HttpContext);
     if (ModelState.IsValid)
     {
         _context.Add(equipment);
         await _context.SaveChangesAsync();
     }
     return(Redirect("/Admin/Equipments/Index/" + equipment.Room_ID));
 }
Beispiel #12
0
        // GET: Admin/Rooms
        public async Task <IActionResult> Index(int status = 1)
        {
            Middleware.CheckStafLogin(HttpContext);
            var dPContext = _context.Rooms.Include(r => r.Cinema).Where(c => c.Status == status);

            ViewBag.ListRoom = await dPContext.ToListAsync();

            ViewData["Cinema_ID"] = new SelectList(_context.Cinemas, "ID", "Name");
            return(View());
        }
        // GET: Admin/Cinemas
        public async Task <IActionResult> Index(int status = 1)
        {
            Middleware.CheckStafLogin(HttpContext);
            var dPContext = _context.Cinemas.Include(c => c.Staf).Where(c => c.Status == status);

            ViewBag.ListCinema = await dPContext.ToListAsync();

            ViewData["Manager_ID"] = new SelectList(_context.Stafs, "ID", "Email");
            return(View());
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Image_1,Image_2,Trailer,Directors,Cast,Genre,Release_Date,Running_Time,Language,Rated,Desc,Keyword,Slug,Status")] Movie movie, IFormFile ful, IFormFile ful_2)
        {
            Middleware.CheckStafLogin(HttpContext);
            if (id != movie.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (ful != null)
                    {
                        var tenImg = movie.ID + "_1." + ful.FileName.Split(".")[ful.FileName.Split(".").Length - 1];
                        var path   = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Uploads/Movie", movie.Image_1);
                        System.IO.File.Delete(path);
                        path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Uploads/Movie", tenImg);
                        using (var stream = new FileStream(path, FileMode.Create))
                        {
                            await ful.CopyToAsync(stream);
                        }
                        movie.Image_1 = tenImg;
                    }
                    if (ful_2 != null)
                    {
                        var tenImg_2 = movie.ID + "_2." + ful_2.FileName.Split(".")[ful_2.FileName.Split(".").Length - 1];
                        var path_2   = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Uploads/Movie", movie.Image_2);
                        System.IO.File.Delete(path_2);
                        path_2 = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Uploads/Movie", tenImg_2);
                        using (var stream = new FileStream(path_2, FileMode.Create))
                        {
                            await ful_2.CopyToAsync(stream);
                        }
                        movie.Image_2 = tenImg_2;
                    }
                    _context.Update(movie);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieExists(movie.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
Beispiel #15
0
        public async Task <IActionResult> Create([Bind("ID,Name,Capacity,Length,Width,Status,Cinema_ID")] Room room)
        {
            Middleware.CheckStafLogin(HttpContext);
            if (ModelState.IsValid)
            {
                _context.Add(room);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Create([Bind("ID,Name,Address,Hotline,Status,Manager_ID")] Cinema cinema)
        {
            Middleware.CheckStafLogin(HttpContext);
            if (ModelState.IsValid)
            {
                _context.Add(cinema);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(RedirectToAction(nameof(Index)));
        }
Beispiel #17
0
        // GET: Admin/Movie_Show
        public async Task <IActionResult> ListInRoom(int id)
        {
            Middleware.CheckStafLogin(HttpContext);
            if (id.ToString() == null)
            {
                return(NotFound());
            }
            var room = _context.Rooms.Where(r => r.ID.Equals(id)).First();

            ViewBag.Room = room;
            var dPContext = _context.Movie_Shows.Include(m => m.Movie).Include(m => m.Room).Where(m => m.Room_ID.Equals(id)).OrderBy(m => m.Start_Show);

            return(View(await dPContext.ToListAsync()));
        }
        // GET: Admin/Movies/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            Middleware.CheckStafLogin(HttpContext);
            if (id == null)
            {
                return(NotFound());
            }

            var movie = await _context.Movies.FindAsync(id);

            if (movie == null)
            {
                return(NotFound());
            }
            return(View(movie));
        }
        // GET: Admin/Category_Equipment/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            Middleware.CheckStafLogin(HttpContext);
            if (id == null)
            {
                return(NotFound());
            }

            var category_Equipment = await _context.Category_Equipment.FindAsync(id);

            if (category_Equipment == null)
            {
                return(NotFound());
            }
            return(View(category_Equipment));
        }
Beispiel #20
0
        // GET: Admin/Equipments
        public async Task <IActionResult> Index(int?id)
        {
            Middleware.CheckStafLogin(HttpContext);
            if (id == null)
            {
                return(NotFound());
            }

            var room = _context.Rooms.Find(id);
            var listCategory_Equipment = _context.Category_Equipment.ToList();
            var listEquipment          = _context.Equipments.Include(e => e.Category_Equipment).Where(e => e.Room_ID.Equals(id)).ToList();

            ViewBag.Room = room;
            ViewBag.listCategory_Equipment = listCategory_Equipment;
            ViewBag.listEquipment          = listEquipment;
            return(View());
        }
Beispiel #21
0
        // GET: Admin/Equipments/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            Middleware.CheckStafLogin(HttpContext);
            if (id == null)
            {
                return(NotFound());
            }

            var equipment = await _context.Equipments.FindAsync(id);

            if (equipment == null)
            {
                return(NotFound());
            }
            ViewData["Equipment_Level_ID"] = new SelectList(_context.Category_Equipment, "ID", "Name", equipment.Equipment_Level_ID);
            ViewData["Room_ID"]            = new SelectList(_context.Rooms, "ID", "Name", equipment.Room_ID);
            return(View(equipment));
        }
Beispiel #22
0
        // GET: Admin/Stafs/Delete/5
        public async Task <IActionResult> Delete(int?id)
        {
            Middleware.CheckStafLogin(HttpContext);
            if (id == null)
            {
                return(NotFound());
            }

            var staf = await _context.Stafs
                       .FirstOrDefaultAsync(m => m.ID == id);

            if (staf == null)
            {
                return(NotFound());
            }

            return(View(staf));
        }
        // GET: Admin/Movies/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            Middleware.CheckStafLogin(HttpContext);
            if (id == null)
            {
                return(NotFound());
            }

            var movie = await _context.Movies
                        .FirstOrDefaultAsync(m => m.ID == id);

            if (movie == null)
            {
                return(NotFound());
            }

            return(View(movie));
        }
Beispiel #24
0
        // GET: Admin/Movie_Show/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            Middleware.CheckStafLogin(HttpContext);
            if (id == null)
            {
                return(NotFound());
            }

            var movie_Show = _context.Movie_Shows.Include(m => m.Room.Cinema).Where(m => m.ID.Equals(id)).First();

            if (movie_Show == null)
            {
                return(NotFound());
            }
            ViewData["Movie_ID"] = new SelectList(_context.Movies, "ID", "Directors", movie_Show.Movie_ID);
            ViewData["Room_ID"]  = new SelectList(_context.Rooms, "ID", "Name", movie_Show.Room_ID);
            return(View(movie_Show));
        }
        // GET: Admin/Category_Equipment/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            Middleware.CheckStafLogin(HttpContext);
            if (id == null)
            {
                return(NotFound());
            }

            var category_Equipment = await _context.Category_Equipment
                                     .FirstOrDefaultAsync(m => m.ID == id);

            if (category_Equipment == null)
            {
                return(NotFound());
            }

            return(View(category_Equipment));
        }
Beispiel #26
0
        // GET: Admin/Equipments/Delete/5
        public async Task <IActionResult> Delete(int?id)
        {
            Middleware.CheckStafLogin(HttpContext);
            if (id == null)
            {
                return(NotFound());
            }

            var equipment = await _context.Equipments
                            .Include(e => e.Category_Equipment)
                            .Include(e => e.Room)
                            .FirstOrDefaultAsync(m => m.ID == id);

            if (equipment == null)
            {
                return(NotFound());
            }

            return(View(equipment));
        }
Beispiel #27
0
        // GET: Admin/Movie_Show/Delete/5
        public async Task <IActionResult> Delete(int?id)
        {
            Middleware.CheckStafLogin(HttpContext);
            if (id == null)
            {
                return(NotFound());
            }

            var movie_Show = await _context.Movie_Shows
                             .Include(m => m.Movie)
                             .Include(m => m.Room)
                             .FirstOrDefaultAsync(m => m.ID == id);

            if (movie_Show == null)
            {
                return(NotFound());
            }

            return(View(movie_Show));
        }
Beispiel #28
0
 public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Email,Password,Avatar,Phone,Address,Status")] Staf staf, IFormFile ful)
 {
     Middleware.CheckStafLogin(HttpContext);
     if (id != staf.ID)
     {
         return(NotFound());
     }
     if (ModelState.IsValid)
     {
         try
         {
             if (ful != null)
             {
                 var tenImg = staf.ID + "." + ful.FileName.Split(".")[ful.FileName.Split(".").Length - 1];
                 var path   = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Uploads/Staf", staf.Avatar);
                 System.IO.File.Delete(path);
                 path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Uploads/Staf", tenImg);
                 using (var stream = new FileStream(path, FileMode.Create))
                 {
                     await ful.CopyToAsync(stream);
                 }
                 staf.Avatar = tenImg;
             }
             _context.Update(staf);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!StafExists(staf.ID))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(View(staf));
 }
Beispiel #29
0
        public async Task <IActionResult> Create([Bind("ID,Start_Show,Status,Room_ID,Movie_ID")] Movie_Show movie_Show)
        {
            Middleware.CheckStafLogin(HttpContext);
            var room = _context.Rooms.Where(m => m.ID.Equals(movie_Show.Room_ID)).First();

            if (ModelState.IsValid)
            {
                var listShowInRoom = _context.Movie_Shows.Where(s => s.Room_ID.Equals(movie_Show.Room_ID)).Where(s => s.Start_Show.Date.Equals(movie_Show.Start_Show.Date)).ToList();
                var movie          = _context.Movies.Where(s => s.ID.Equals(movie_Show.Movie_ID)).First();
                int total_m        = ConvertToMinute(movie_Show.Start_Show);
                int col            = total_m / 10;
                int cell           = movie.Running_Time / 10;
                if (movie.Running_Time % 10 > 0)
                {
                    cell = cell + 1;
                }
                if (col > (132 - cell + 1))
                {
                    //ViewBag.ERROR = "Không Đủ Khoảng Trống Để Thêm Ghế " + seat_lv.Name;
                    return(Redirect("/Admin/Movie_Show?idCinema=" + room.Cinema_ID + "&date=" + movie_Show.Start_Show.Date));
                }
                foreach (var item in listShowInRoom)
                {
                    col = total_m / 10;
                    for (int i = 1; i <= cell; i++)
                    {
                        if (col == (ConvertToMinute(item.Start_Show) / 10))
                        {
                            //ViewBag.ERROR = "Không Đủ Khoảng Trống Để Thêm Ghế " + seat_lv.Name;
                            return(Redirect("/Admin/Movie_Show?idCinema=" + room.Cinema_ID + "&date=" + movie_Show.Start_Show.Date));
                        }
                        col++;
                    }
                }
                _context.Add(movie_Show);
                await _context.SaveChangesAsync();
            }
            return(Redirect("/Admin/Movie_Show?idCinema=" + room.Cinema_ID + "&date=" + movie_Show.Start_Show.Date));
        }
Beispiel #30
0
        public async Task <IActionResult> Create([Bind("ID,Name,Email,Password,Avatar,Phone,Address,Status")] Staf staf, IFormFile ful)
        {
            Middleware.CheckStafLogin(HttpContext);
            if (ModelState.IsValid)
            {
                staf.Password = StringProcessing.CreateMD5(staf.Password);
                _context.Add(staf);
                await _context.SaveChangesAsync();

                var tenImg = staf.ID + "." + ful.FileName.Split(".")[ful.FileName.Split(".").Length - 1];
                var path   = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Uploads/Staf", tenImg);
                using (var stream = new FileStream(path, FileMode.Create))
                {
                    await ful.CopyToAsync(stream);
                }
                staf.Avatar = tenImg;
                _context.Update(staf);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(staf));
        }