Пример #1
0
        public ActionResult AddNewFilm(HttpPostedFileBase file, HttpPostedFileBase banner, String reissue,  String genre, String country, String content, PhimViewModels fvm)//String name, String rank, String actor,
        //    String director, String duration, String reissue, String genre, String country, String content, String trailer)
        {
            String fileName = "";
            if (file != null && file.ContentLength > 0)
            {
                fileName = Path.GetFileName(file.FileName);
                var path = Path.Combine(Server.MapPath("~/Images/"), fileName);
                file.SaveAs(path);
            }
            else
            {
                fileName = "defaultAvatar.jpg";
            }


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


            Phim p = new Phim();
            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;
            p.HinhAnh = "/Images/" + fileName;
            p.AnhBanner = "/Images/" + fileNameBanner;
            FilmService filmsv = new FilmService();

            TempData["CreateFilmResult"] = filmsv.addNewFilmd(p);
            return RedirectToAction("CreateFilmResult");
    



           
        }