public JsonResult Get(int id) { var category = new CategoryFilm(); category = ApiHelper <CategoryFilm> .HttpGetAsync($"{Helper.ApiUrl}api/CategoryFilm/GetbyCateId/{id}"); return(Json(new { category })); }
// [ValidateAntiForgeryToken] public ActionResult Create(FilmViewModel model) { var imageTypes = new string[] { "image/gif", "image/jpeg", "image/pjpeg", "image/png" }; // if (model.Image == null || model.Image.ContentLength == 0) // { // ModelState.AddModelError("ImageUpload", "Додайте зображення"); // } if (model.Image != null && !imageTypes.Contains(model.Image.ContentType)) { ModelState.AddModelError("Image", "Зображення повинне бути у GIF, JPG або PNG форматі."); } else if (model.CategoryId == null) { ModelState.AddModelError("CategoryId", "Додайте жанр"); } if (ModelState.IsValid) { var film = new Movie(); film.Name = model.Name; film.Description = model.Description; if (model.CategoryId != null) { foreach (var c in model.CategoryId) { if (_context.Categories.Find(c) != null) { var categoryFilm = new CategoryFilm(); categoryFilm.Category = _context.Categories.Find(c); categoryFilm.Film = film; film.Categories.Add(categoryFilm); } } } if (model.Image != null) { var bytes = BytesFromStream(model.Image.OpenReadStream()); ViewBag.Width = 100; ViewBag.Height = 100; film.Image = bytes; } _context.Films.Add(film); _context.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Categories = _context.Categories.ToList(); return(View(model)); }
public IActionResult FilmShow(int id) { ViewBag.Title = "Film NPT"; var category = new CategoryFilm(); category = ApiHelper <CategoryFilm> .HttpGetAsync($"{Helper.ApiUrl}api/CategoryFilm/GetbyCateId/{id}"); if (category != null) { ViewBag.Category = category; } ViewBag.FilmId = id; return(View()); }
public IActionResult FilmNowShowing(int id) { ViewBag.Title = "Film NPT"; var category = new CategoryFilm(); category = ApiHelper <CategoryFilm> .HttpGetAsync($"{Helper.ApiUrl}api/CategoryFilm/GetbyCateId/{id}"); if (category != null) { ViewBag.Category = category; } List <Film> films = new List <Film>(); films = ApiHelper <List <Film> > .HttpGetAsync($"{Helper.ApiUrl}api/film/GetFilmNowShowing/{id}"); ViewBag.CategoryId = id; return(View(films)); }
public IActionResult AddShowingOfFilmNew() { ViewBag.Title = "Thêm xuất chiếu phim"; var films = new List <Film>(); films = ApiHelper <List <Film> > .HttpGetAsync($"{Helper.ApiUrl}api/film/GetfilmsNew"); List <CategoryFilm> listcategory = new List <CategoryFilm>(); for (int i = 0; i < films.Count; i++) { var category = new CategoryFilm(); category = ApiHelper <CategoryFilm> .HttpGetAsync($"{Helper.ApiUrl}api/CategoryFilm/GetbyCateId/{films[i].CategoryId}"); listcategory.Add(category); } ViewBag.listcategory = listcategory; ViewBag.Films = films; return(View()); }
public ActionResult Edit(Movie model, int[] selectedCategories, IFormFile upload = null) { if (ModelState.IsValid) { var film = _context.Films.Find(model.Id); if (film == null) { return(BadRequest()); } film.Name = model.Name; film.Description = model.Description; if (selectedCategories != null) { film.Categories.Clear(); foreach (var c in selectedCategories) { if (_context.Categories.Find(c) != null) { var categoryFilm = new CategoryFilm(); categoryFilm.Category = _context.Categories.Find(c); categoryFilm.Film = film; film.Categories.Add(categoryFilm); } } } if (upload != null) { var bytes = BytesFromStream(upload.OpenReadStream()); ViewBag.Width = 100; ViewBag.Height = 100; film.Image = bytes; } _context.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
public bool Update(CategoryFilm entity) { return(_categoryFilmRepository.Update(entity)); }
public bool Insert(CategoryFilm entity) { return(_categoryFilmRepository.Insert(entity)); }