Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("id,name,summery,poster,trailer_path,status,duration,published_date")] Movie movie)
        {
            if (id != movie.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    string str = movie.trailer_path;
                    if (movie.trailer_path != null)
                    {
                        str = str.Substring(str.IndexOf("=") + 1);
                    }
                    movie.trailer_path = str;
                    _context.Update(movie);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieExists(movie.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("id,reason,content,review_id,create_date,status")] Report report)
        {
            if (id != report.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(report);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReportExists(report.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["review_id"] = new SelectList(_context.reviews, "id", "id", report.review_id);
            return(View(report));
        }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("id,user_id,movie_id,content,heart_rate,create_date")] Review review)
        {
            if (id != review.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(review);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReviewExists(review.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["movie_id"] = new SelectList(_context.movies, "id", "id", review.movie_id);
            ViewData["user_id"]  = new SelectList(_context.users, "id", "id", review.user_id);
            return(View(review));
        }
Пример #4
0
        public async Task <IActionResult> Edit(int id, [Bind("id,user_id,total_price,status,create_date")] Order order)
        {
            if (id != order.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(order);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderExists(order.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["user_id"] = new SelectList(_context.users, "id", "id", order.user_id);
            return(View(order));
        }
Пример #5
0
        public async Task <IActionResult> Edit(int id, [Bind("id,branch_id,name,status")] Room room)
        {
            if (id != room.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                SetNotification("Edited success !");
                try
                {
                    _context.Update(room);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    SetNotification("Edited fail !");
                    if (!RoomExists(room.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["branch_id"] = new SelectList(_context.branches, "id", "address", room.branch_id);
            return(View(room));
        }
Пример #6
0
        public async Task <IActionResult> Edit(int id, [Bind("id,room_id,position")] Seat seat)
        {
            if (id != seat.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(seat);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SeatExists(seat.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["room_id"] = new SelectList(_context.rooms, "id", "name", seat.room_id);
            return(View(seat));
        }
Пример #7
0
        public async Task <IActionResult> Edit(int id, [Bind("id,name,status")] Category category)
        {
            if (id != category.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(category);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryExists(category.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Пример #8
0
        public async Task <IActionResult> Edit(int id, [Bind("id,name,address,status")] Branch branch)
        {
            if (id != branch.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    SetAlert("Edited success !");
                    _context.Update(branch);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    SetAlert("Edited fail !");
                    if (!BranchExists(branch.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(branch));
        }
Пример #9
0
        public async Task <IActionResult> Edit(int id, [Bind("id,user_id,content,status,create_date")] ContactForm contactForm)
        {
            if (id != contactForm.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(contactForm);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContactFormExists(contactForm.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["user_id"] = new SelectList(_context.users, "id", "id", contactForm.user_id);
            return(View(contactForm));
        }
Пример #10
0
        public async Task <IActionResult> Edit(int id, [Bind("id,order_id,schedule_id,price")] Ticket ticket)
        {
            if (id != ticket.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ticket);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TicketExists(ticket.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["order_id"]    = new SelectList(_context.orders, "id", "id", ticket.order_id);
            ViewData["schedule_id"] = new SelectList(_context.schedules, "id", "id", ticket.schedule_id);
            return(View(ticket));
        }
Пример #11
0
        public async Task <IActionResult> Edit(int id, [Bind("id,name,discount_percent,status")] Discount discount)
        {
            if (id != discount.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(discount);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DiscountExists(discount.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(discount));
        }
Пример #12
0
        public async Task <IActionResult> Edit(int id, [Bind("id,room_id,movie_id,start_time")] Schedule schedule)
        {
            if (id != schedule.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(schedule);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ScheduleExists(schedule.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["movie_id"] = new SelectList(_context.movies, "id", "name", schedule.movie_id);
            ViewData["room_id"]  = new SelectList(_context.rooms, "id", "name", schedule.room_id);
            return(View(schedule));
        }
Пример #13
0
        public async Task <IActionResult> Create([Bind("id,username,password,displayname,email,birthday,avatar,rule")] User user, IFormFile ful)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                string path = Path.Combine(
                    Directory.GetCurrentDirectory(), "wwwroot/Admin/assets/images/user",
                    user.id + "." + ful.FileName.Split(".")[ful.FileName.Split(".").Length - 1]
                    );
                using (var stream = new FileStream(path, FileMode.Create))
                {
                    await ful.CopyToAsync(stream);
                }
                user.avatar = user.id + "." + ful.FileName.Split(".")[ful.FileName.Split(".").Length - 1];
                _context.Update(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Пример #14
0
        public async Task <IActionResult> Create([Bind("id,name,image")] Actor actor, IFormFile ful)
        {
            if (ModelState.IsValid)
            {
                _context.Add(actor);
                await _context.SaveChangesAsync();

                string path = Path.Combine(
                    Directory.GetCurrentDirectory(), "wwwroot/Admin/assets/images/actor",
                    actor.id + "." + ful.FileName.Split(".")[ful.FileName.Split(".").Length - 1]
                    );
                using (var stream = new FileStream(path, FileMode.Create))
                {
                    await ful.CopyToAsync(stream);
                }
                actor.image = actor.id + "." + ful.FileName.Split(".")[ful.FileName.Split(".").Length - 1];
                _context.Update(actor);
                await _context.SaveChangesAsync();

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