public async Task <String> CheckEditFilm(String _name, String _synopsis, String _ageMini, int _genre)
        {
            //Vérifie tout les champs et retourne une erreur si champs vides.
            if (_name.Equals("") || _synopsis.Equals("") || _ageMini.Equals("") || _genre == -1) // -1 = combobox vide
            {
                return("Veuillez remplir tous les champs");
            }
            else
            {
                await FilmService.EditFilm(ViewModel.Film.Id, _name, _synopsis, Convert.ToInt32(_ageMini), Convert.ToInt32(_genre) + 1);

                ViewModel.Source = NavigationServices.GetPage <Films, FilmsViewModel>(ViewModel);
                return("Success");
            }
        }
Beispiel #2
0
        public async Task <IActionResult> EditFilm(int id)
        {
            var form = await _filmService.EditFilm(id);

            return(form == null ? (IActionResult) new NotFoundResult() : View(form));
        }
Beispiel #3
0
        public ActionResult EditFilm(HttpPostedFileBase file, HttpPostedFileBase banner, String reissue, String genre, String country, String content, String codeFilm, PhimViewModels fvm)
        {
            String fileName = "";

            if (file != null && file.ContentLength > 0)
            {
                fileName = Path.GetFileName(file.FileName);
                var path = Path.Combine(Server.MapPath("~/Images/"), fileName);
                file.SaveAs(path);
            }

            String fileNameBanner = "";

            if (banner != null && banner.ContentLength > 0)
            {
                fileNameBanner = Path.GetFileName(banner.FileName);
                var path = Path.Combine(Server.MapPath("~/Images/"), fileNameBanner);
                banner.SaveAs(path);
            }



            Phim p = new Phim();

            p.MaSo         = Int32.Parse(codeFilm);
            p.DiemDanhGia  = fvm.DiemDanhGia;
            p.NoiDung      = content;
            p.NgayPhatHanh = DateTime.ParseExact(reissue, "MM/dd/yyyy", null);;
            p.TenPhim      = fvm.TenPhim;
            p.TinhTrang    = true;
            p.ThoiLuong    = fvm.ThoiLuong;
            p.DaoDien      = fvm.DaoDien;
            p.DienVien     = fvm.DienVien;
            if (genre != "")
            {
                p.MS_TheLoai = Int32.Parse(genre);
            }
            if (country != "")
            {
                p.MS_NuocSX = Int32.Parse(country);
            }
            p.URL_Trailer = fvm.URL_Trailer;


            //Nếu người dùng không upload ảnh mới thì sẽ lấy lại ảnh cũ
            if (fileName != "")
            {
                p.HinhAnh = "/Images/" + fileName;
            }
            else
            {
                p.HinhAnh = (String)TempData["currentAvatar"];
            }


            if (fileNameBanner != "")
            {
                p.AnhBanner = "/Images/" + fileNameBanner;
            }
            else
            {
                p.AnhBanner = (String)TempData["currentBanner"];
            }

            FilmService filmsv = new FilmService();

            filmsv.EditFilm(p);



            return(RedirectToAction("Index"));
        }