Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,DivertismentTypeId,Title,GenreId,UserId,Description,Trailer,ImagePath")] ComingSoon comingSoon)
        {
            if (id != comingSoon.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(comingSoon);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WatchListExists(comingSoon.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DivertismentTypeId"] = new SelectList(_context.DivertismentTypes, "Id", "DivertismentType", comingSoon.DivertismentTypeId);
            ViewData["GenreId"]            = new SelectList(_context.Genres, "Id", "Genre", comingSoon.GenreId);
            ViewData["UserId"]             = new SelectList(_context.Users, "Id", "Username", comingSoon.UserId);
            return(View(comingSoon));
        }
Example #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            ComingSoon comingSoon = db.ComingSoons.Find(id);

            db.ComingSoons.Remove(comingSoon);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #3
0
 public ActionResult Edit([Bind(Include = "Id,Movie_Id,rating,ReleaseDate")] ComingSoon comingSoon)
 {
     if (ModelState.IsValid)
     {
         db.Entry(comingSoon).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Movie_Id = new SelectList(db.MoviesComingSoons, "Movie_Id", "Tilte", comingSoon.Movie_Id);
     return(View(comingSoon));
 }
Example #4
0
        // GET: ComingSoons/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ComingSoon comingSoon = db.ComingSoons.Find(id);

            if (comingSoon == null)
            {
                return(HttpNotFound());
            }
            return(View(comingSoon));
        }
Example #5
0
        // GET: ComingSoons/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ComingSoon comingSoon = db.ComingSoons.Find(id);

            if (comingSoon == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Movie_Id = new SelectList(db.MoviesComingSoons, "Movie_Id", "Tilte", comingSoon.Movie_Id);
            return(View(comingSoon));
        }
Example #6
0
        public async Task <IActionResult> Create([Bind("Id,DivertismentTypeId,Title,GenreId,UserId,Description,Trailer,ImagePath")] ComingSoon comingSoon, IFormFile image)
        {
            if (ModelState.IsValid)
            {
                if (image != null && image.Length > 0)
                {
                    var fileName = Path.GetFileName(image.FileName);
                    var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images\\items", fileName);
                    using (var fileSteam = new FileStream(filePath, FileMode.Create))
                    {
                        await image.CopyToAsync(fileSteam);
                    }
                    comingSoon.ImagePath = fileName;
                }
                _context.Add(comingSoon);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DivertismentTypeId"] = new SelectList(_context.DivertismentTypes, "Id", "Id", comingSoon.DivertismentTypeId);
            ViewData["GenreId"]            = new SelectList(_context.Genres, "Id", "Id", comingSoon.GenreId);
            ViewData["UserId"]             = new SelectList(_context.Users, "Id", "Id", comingSoon.UserId);
            return(View(comingSoon));
        }