public ActionResult Index() { List <CinemaModel> cinemas = CinemaManager.GetCinemas().Select(c => CinemaModel.FromData(c)).ToList(); return(View(cinemas)); }
/// <summary> /// 获取管理员列表(全部) /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public JsonRsp <CinemaViewModel> GetAllList() { JsonRsp <CinemaViewModel> rsp = new JsonRsp <CinemaViewModel>(); CinemaModel model = new CinemaModel(); OQL q = OQL.From(model) .Select() .OrderBy(model.ID, "asc") .END; List <CinemaModel> list = q.ToList <CinemaModel>();//使用OQL扩展 rsp.data = list.ConvertAll <CinemaViewModel>(o => { return(new CinemaViewModel() { ID = o.ID, CinemaName = o.CinemaName, CreateBy = o.CreateUser, CreateIP = o.CreateIP, CreateTime = o.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), Sort = o.Sort, Status = o.Status, UpdateBy = o.UpdateUser, UpdateIP = o.UpdateIP, UpdateTime = o.UpdateTime == null ? "" : Convert.ToDateTime(o.UpdateTime).ToString("yyyy-MM-dd HH:mm:ss"), }); } ); rsp.success = true; rsp.code = 0; return(rsp); }
/// <summary> /// 改 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonRsp Update(CinemaModel model) { int returnvalue = EntityQuery <CinemaModel> .Instance.Update(model); return(new JsonRsp { success = returnvalue > 0, code = returnvalue }); }
// public ActionResult PlayMovie() { int? vidId = 108; CinemaModel model = new CinemaModel(); model.VideoPath = vidId.Value.ToString() + ".mp4"; return(View(model)); }
public ActionResult AddVideo() { CinemaModel cm = new CinemaModel(); Movie m = new Movie(); cm.Categories = From(_movieCategoryService.GetAll()); cm.Movie = m; return(View(cm)); }
public async Task <ActionResult> Post([FromBody] CinemaModel cinemaModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } CinemaDomainModel cinemaWithoutAuditorium = new CinemaDomainModel() { Name = cinemaModel.Name }; CreateCinemaWithAuditoriumModel cinemaWithAuditoriumModel = new CreateCinemaWithAuditoriumModel { AuditoriumName = cinemaModel.auditName, CinemaName = cinemaModel.Name, NumberOfRows = cinemaModel.seatRows, NumberOfColumns = cinemaModel.numberOfSeats }; CreateCinemaResultModel createCinema; try { if (cinemaModel.auditName != null && cinemaModel.numberOfSeats > 0 && cinemaModel.seatRows > 0) { createCinema = await _cinemaService.AddCinemaWithAuditorium(cinemaWithAuditoriumModel); } else { createCinema = await _cinemaService.AddCinema(cinemaWithoutAuditorium); } } catch (DbUpdateException e) { ErrorResponseModel errorResponse = new ErrorResponseModel { ErrorMessage = e.InnerException.Message ?? e.Message, StatusCode = System.Net.HttpStatusCode.BadRequest }; return(BadRequest(errorResponse)); } if (createCinema.IsSuccessful != true) { ErrorResponseModel errorResponse = new ErrorResponseModel() { ErrorMessage = createCinema.ErrorMessage, StatusCode = System.Net.HttpStatusCode.BadRequest }; return(BadRequest(errorResponse)); } return(Created("cinemas//" + createCinema.Cinema.Id, createCinema.Cinema)); }
/// <summary> /// save /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonRsp Save(CinemaModel model) { if (model.ID == 0) { return(Add(model)); } else { return(Update(model)); } }
/// <summary> /// 增 /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonRsp Add(CinemaModel model) { //salt string strSalt = Guid.NewGuid().ToString(); model.CreateUser = AdminName; model.CreateIP = Util.GetLocalIP(); model.CreateTime = DateTime.Now; int returnvalue = EntityQuery <CinemaModel> .Instance.Insert(model); return(new JsonRsp { success = returnvalue > 0, code = returnvalue }); }
/// <summary> /// save /// </summary> /// <param name="model"></param> /// <returns></returns> public JsonRsp DeleteById(long[] Ids) { //删除 测试数据----------------------------------------------------- CinemaModel user = new CinemaModel(); OQL deleteQ = OQL.From(user) .Delete() .Where(cmp => cmp.Comparer(user.ID, "IN", Ids)) //为了安全,不带Where条件是不会全部删除数据的 .END; int returnvalue = EntityQuery <CinemaModel> .Instance.ExecuteOql(deleteQ); return(new JsonRsp { success = returnvalue > 0, code = returnvalue }); }
public ActionResult Edit(CinemaModel cinema) { if (ModelState.IsValid) { if (cinema.Id != 0) { CinemaManager.Update(cinema.ToData()); } else { CinemaManager.Create(cinema.ToData()); } } return(View(cinema)); }
public async Task <int> UpsertCinemaAsync(CinemaModel cinemaModel) { try { int cinemaId = await _cinemaRepository.UpsertCinemaAsync( cinemaModel.Adapt <CinemaEntity>() ); return(cinemaId); } catch (UniqueIndexException e) { throw new ConflictException(e); } }
[HttpGet] // get nozīmē apskates forma public ActionResult Edit(int?id) // šis bloks nepieciešams lietotāja datu attēlošanai . Jautājuma zīme norāda, ka id var būt tukšs { CinemaModel cinema = null; // jādefinē kinoteātris, kas jālabo vai jāpievieno if (id.HasValue) // ja ID ir definēts, tiek veikta rediģēšana { cinema = CinemaModel.FromData(CinemaManager.GetCinema(id.Value)); cinema.Movies = MovieManager.GetMovies(id.Value).Select(m => MovieModel.FromData(m)).ToList(); } else { cinema = new CinemaModel(); // ja id nav definēts, tad kinoteātri neatlasam, pievienojam tukšu, lai nav problēmas ar Id lauku } return(View(cinema)); }
[HttpPost] // post nozīmē datu iesūtīšana public ActionResult Edit(CinemaModel cinema) { if (ModelState.IsValid) // iebūvēta funkcija, kas pārbauda vai dati atbilst definētajiem { if (cinema.Id != 0) // ja Id ir nav definēts, tad labojam { CinemaManager.Update(cinema.ToData()); } else { CinemaManager.Create(cinema.ToData()); } } return(View(cinema)); }
public async Task <IActionResult> GetCinemaModel([FromRoute] int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } CinemaModel cinemaModel = await _context.CinemaModel.SingleOrDefaultAsync(m => m.CineplexID == id); if (cinemaModel == null) { return(NotFound()); } return(Ok(cinemaModel)); }
/// <summary> /// 查 根据Id获取详情,如果没有则返回空对象 /// </summary> /// <param name="customerID"></param> /// <returns></returns> public CinemaModel GetModelById(int accountId) { CinemaModel model = new CinemaModel() { ID = accountId }; if (EntityQuery <CinemaModel> .Fill(model)) { return(model); } else { return(null); } }
public async Task <int> AddOrUpdateCinema(CinemaModel cinema) { using (SqlConnection connection = new SqlConnection(_settings.ConnectionString)) { int id = await connection.ExecuteScalarAsync <int>( "AddOrUpdateCinema", new { Id = cinema.Id, Name = cinema.Name, City = cinema.City }, commandType : CommandType.StoredProcedure); return(id); } }
public ActionResult Edit(int?id) { CinemaModel cinema = null; // ja ID ir definēts -> tiek veikta rediģēšana if (id.HasValue) { cinema = CinemaModel.FromData(CinemaManager.GetCinema(id.Value)); cinema.Movies = MovieManager.GetMovies(id.Value).Select(m => MovieModel.FromData(m)).ToList(); } // citādi tiek veikta pievienošana else { cinema = new CinemaModel(); } return(View(cinema)); }
/// <summary> /// 获取管理员列表(分页) /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public JsonRsp <CinemaViewModel> GetPageList(int pageIndex, int pageSize) { JsonRsp <CinemaViewModel> rsp = new JsonRsp <CinemaViewModel>(); CinemaModel m = new CinemaModel(); OQL q = OQL.From(m) .Select() .OrderBy(m.ID, "asc") .END; //分页 q.Limit(pageSize, pageIndex, true); //q.PageWithAllRecordCount = allCount; //List<Employee> list= EntityQuery<Employee>.QueryList(q); List <CinemaModel> list = q.ToList <CinemaModel>();//使用OQL扩展 rsp.data = list.ConvertAll <CinemaViewModel>(o => { return(new CinemaViewModel() { ID = o.ID, CinemaChainId = o.CinemaChainId, CinemaName = o.CinemaName, LinkPhone = o.LinkPhone, LinkName = o.LinkName, LinkMobile = o.LinkMobile, CinemaArea = o.CinemaArea, CinemaAddress = o.CinemaAddress, CreateBy = o.CreateUser, CreateIP = o.CreateIP, CreateTime = o.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), Sort = o.Sort, Status = o.Status, UpdateBy = o.UpdateUser, UpdateIP = o.UpdateIP, UpdateTime = o.UpdateTime == null ? "" : Convert.ToDateTime(o.UpdateTime).ToString("yyyy-MM-dd HH:mm:ss"), }); } ); rsp.success = true; rsp.code = 0; rsp.count = q.PageWithAllRecordCount; return(rsp); }
public async Task <ActionResult> Put(int id, [FromBody] CinemaModel cinemaModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } CinemaDomainModel cinemaToUpdate; cinemaToUpdate = await _cinemaService.GetCinemaByIdAsync(id); if (cinemaToUpdate == null) { ErrorResponseModel errorResponse = new ErrorResponseModel { ErrorMessage = Messages.CINEMA_DOES_NOT_EXIST, StatusCode = System.Net.HttpStatusCode.BadRequest }; return(BadRequest(errorResponse)); } cinemaToUpdate.Name = cinemaModel.Name; CinemaDomainModel cinemaDomainModel; try { cinemaDomainModel = await _cinemaService.UpdateCinema(cinemaToUpdate); } catch (DbUpdateException e) { ErrorResponseModel errorResponse = new ErrorResponseModel { ErrorMessage = e.InnerException.Message ?? e.Message, StatusCode = System.Net.HttpStatusCode.BadRequest }; return(BadRequest(errorResponse)); } return(Accepted("cinemas//" + cinemaDomainModel.Id, cinemaDomainModel)); }
// GET: Home public ActionResult Home(int?id) { Home model = new Home(); model.Cinemas = CinemaManager.GetCinemas().Select(c => CinemaModel.FromData(c)).ToList(); foreach (var cinema in model.Cinemas) { cinema.MovieCount = CinemaManager.CountMovies(cinema.Id); } if (id.HasValue) { model.Movies = MovieManager.GetMovies(id.Value).Select(m => MovieModel.FromData(m)).ToList(); } else { model.Movies = new List <MovieModel>(); } return(View(model)); }
/// <summary> /// 启用/禁用 /// </summary> /// <param name="accountStatus"></param> /// <returns></returns> public JsonRsp SetStatus(long[] Ids, int status) { if (Ids == null) { return(new JsonRsp { success = false, retmsg = "请选择要操作的数据" }); } CinemaModel user = new CinemaModel(); user.Status = status; OQL q = OQL.From(user) .Update(user.Status) .Where(cmp => cmp.Comparer(user.ID, "IN", Ids)) //为了安全,不带Where条件是不会全部删除数据的 .END; int returnvalue = EntityQuery <CinemaModel> .Instance.ExecuteOql(q); return(new JsonRsp { success = returnvalue > 0, code = returnvalue }); }
public List <CinemaModel> getCinemas() { var data = GetData("Cineplex"); List <CinemaModel> Cinemas = new List <CinemaModel>(); int count = 1; foreach (var item in data) { CinemaModel details = new CinemaModel() { CineplexID = count++, Location = item[1], ShortDescription = item[2], LongDescription = item[3], Address = item[4], }; Cinemas.Add(details); } return(Cinemas); }
public ActionResult AddRemoveChildren(CinemaModel model) { var g = _guestService.GetAll(HotelID).FirstOrDefault(x => x.Id == model.GuestId); var allMusic = _movieService.GetAll().Where(x => x.CategoryId == 8).ToList(); //var existingChildren = g.Movies.ToList(); //g.Movies.Clear(); var selectedVideos = new List <Movie>(); if (model.CurrentBuildingIds != null && model.CurrentBuildingIds.Count() > 0) { foreach (var id in model.CurrentBuildingIds.Distinct()) { selectedVideos.Add(allMusic.FirstOrDefault(x => x.Id == id)); } } if (model.PlayListId == 0) { GuestPlaylist gpl = new GuestPlaylist(); gpl.Name = model.PlaylistName; gpl.Description = model.PlaylistDescription; gpl.GuestId = g.Id; _guestPlaylistService.Create(gpl, selectedVideos); } else { var existingGpl = g.GuestPlaylists.FirstOrDefault(x => x.Id == model.PlayListId); existingGpl.Name = model.PlaylistName; existingGpl.Description = model.PlaylistDescription; _guestPlaylistService.Update(existingGpl, selectedVideos); } return(RedirectToAction("MyPlayList")); }
public ActionResult CreatePlayList(int?id) { var personId = Person.PersonID; var g = _guestService.GetAll(HotelID).FirstOrDefault(x => x.PersonId == personId); CinemaModel model = new CinemaModel(); var everyMusicVideo = _movieService.GetAll().Where(x => x.CategoryId == 8).ToList(); if (g.IsChild) { everyMusicVideo = everyMusicVideo.Where(x => !x.AdultOnly).ToList(); } model.CurrentBuildings = From(new List <Movie>()); model.AllBuildings = From(everyMusicVideo); model.GuestId = g.Id; GuestPlaylist gp = new GuestPlaylist(); model.PlayListId = 0; if (id.HasValue && id.Value > 0) { gp = g.GuestPlaylists.FirstOrDefault(x => x.Id == id.Value); model.PlayListId = id.Value; model.PlaylistDescription = gp.Description; model.PlaylistName = gp.Name; model.CurrentBuildings = From(gp.Movies); } return(View(model)); }
public ActionResult Save(CinemaModel model) { return(Json(bll.Save(model), JsonRequestBehavior.AllowGet)); }
public ActionResult ShowFilm(int?id) { Guest g = _guestService.GetAll(HotelID).FirstOrDefault(x => x.PersonId == Person.PersonID); var everyMovie = _movieService.GetAll().ToList(); var allMovies = everyMovie.Where(x => x.Id == id.Value).ToList(); var allCategories = everyMovie.Select(x => x.MovieCategory.Name).ToList(); CinemaModel model = new CinemaModel(); model.FilmId = id.Value; var movie = allMovies.FirstOrDefault(x => x.Id == id.Value); var posterPath = Url.Content("~/Videos/Posters/" + id.Value.ToString() + ".jpg"); model.MovieType = "mp4"; if (movie.Filename.EndsWith("avi")) { model.MovieType = "avi"; } string origPath = string.Empty; if (movie != null) { origPath = movie.Filename; } if (movie != null) { model.MovieName = movie.Name; } if (g.IsChild && movie.AdultOnly) { return(View("InsufficientRights")); } model.PosterPath = posterPath; model.FileName = movie.Filename; //model.FullPath = @"http://localhost/Videos/Movies/11.mp4"; //model.FullPathWebM = @"http://localhost/Videos/Movies/11.webm"; //model.FullPath = @"http://localhost/Videos/Movies/" + model.FileName; //model.FullPathWebM = @"http://localhost/Videos/Movies/" + id.Value + ".webm"; //model.FullPathImage = @"http://localhost/Videos/Films/" + id.Value + ".jpg"; //var ipPath = GetMovieIP(); //model.FullPath = ipPath + @"Videos/Movies/" + model.FileName; //model.FullPathWebM = ipPath + @"Videos/Movies/" + id.Value + ".webm"; //model.FullPathImage = ipPath + @"Videos/Films/" + id.Value + ".jpg"; //model.CategoryId = movie.CategoryId; //if (model.CategoryId == 8) //{ // model.MusicVideos = everyMovie.Where(x => x.CategoryId == 8 && x.Id != id.Value).Select(x => new MusicVideoModel { MovieName = x.Name, FullPath = GetFullPathIP(x.Id), FullPathWebM = GetFullPathWebmIP(x.Id), FullPathImage = GetFullPathImageIP(x.Id) }).ToList(); //} return(View(model)); }
public ActionResult AddVideo(CinemaModel model, HttpPostedFileBase[] files) { if (files.Count() < 2) { return(RedirectToAction("Joromi")); } var idForPoster = 0; var movieHasBeenCreated = false; foreach (var file in files) { if (file != null && file.ContentLength > 0) { // extract only the fielname var fileName = Path.GetFileName(file.FileName); string ext = Path.GetExtension(fileName); if (ext.EndsWith("mp4")) { Movie m = new Movie(); if (!movieHasBeenCreated) { m.AdultOnly = model.AdultOnly; m.CategoryId = model.CategoryId; m.Name = model.VideoName; m.Starring = model.MovieName; m.Year = "2015"; m.Filename = ".mp4"; m = _movieService.Create(m); idForPoster = m.Id; m.Filename = m.Id.ToString() + ".mp4"; _movieService.Update(m); movieHasBeenCreated = true; } else { m.Filename = idForPoster.ToString() + ".mp4"; } var path = @"C:\inetpub\wwwroot\PublishHotelMotelFinally\Videos\Movies\" + m.Filename; try { path = ConfigurationManager.AppSettings["MoviesStorage"].ToString() + m.Filename; } catch { } file.SaveAs(path); } else if (ext.EndsWith(".jpg")) { //var path = Path.Combine(Server.MapPath("~/App_Data/Uploads"), m.Filename); Movie m = new Movie(); if (!movieHasBeenCreated) { m.AdultOnly = model.AdultOnly; m.CategoryId = model.CategoryId; m.Name = model.VideoName; m.Starring = model.MovieName; m.Year = "2015"; m.Filename = ".mp4"; m = _movieService.Create(m); idForPoster = m.Id; m.Filename = m.Id.ToString() + ".jpg"; _movieService.Update(m); movieHasBeenCreated = true; } else { m.Filename = idForPoster.ToString() + ".jpg"; } var path = @"C:\inetpub\wwwroot\PublishHotelMotelFinally\Videos\Films\" + idForPoster.ToString() + ".jpg"; try { path = ConfigurationManager.AppSettings["FilmPictureStorage"].ToString() + idForPoster.ToString() + ".jpg"; } catch { } file.SaveAs(path); } } } return(RedirectToAction("MyPlaylist")); }
public ActionResult MyPlaylist() { var id = Person.PersonID; var g = _guestService.GetAll(HotelID).FirstOrDefault(x => x.PersonId == id); CinemaModel model = new CinemaModel(); model.GuestName = g.FullName; var lst = g.GuestPlaylists.Count; if (lst == 0) { return(RedirectToAction("CreatePlayList")); } var pls = g.GuestPlaylists.Count; var allMovies = g.GuestPlaylists.FirstOrDefault().Movies.ToList(); if (!allMovies.Any()) { return(RedirectToAction("CreatePlayList")); } if (pls > 1) { model.PlaylistList = g.GuestPlaylists.ToList(); return(View("DisplayPlaylist", model)); } model.PlaylistName = g.GuestPlaylists.FirstOrDefault().Name; var movie = allMovies.FirstOrDefault(); var posterPath = Url.Content("~/Videos/Posters/" + movie.Id.ToString() + ".jpg"); model.MovieType = "mp4"; if (movie.Filename.EndsWith("avi")) { model.MovieType = "avi"; } string origPath = string.Empty; if (movie != null) { origPath = movie.Filename; } if (movie != null) { model.MovieName = movie.Name; } model.PosterPath = posterPath; model.FileName = movie.Filename; //model.FullPath = @"http://localhost/Videos/Movies/" + movie.Filename; //model.FullPathWebM = @"http://localhost/Videos/Movies/" + movie.Id.ToString() + ".webm"; //model.FullPathImage = @"http://localhost/Videos/Films/" + movie.Id.ToString() + ".jpg"; //model.MusicVideos = allMovies.Where(x => x.Id != movie.Id).Select(x => new MusicVideoModel { MovieName = x.Name, FullPath = GetFullPath(x.Id), FullPathWebM = GetFullPathWebm(x.Id), FullPathImage = GetFullPathImage(x.Id) }).ToList(); var ipPath = GetMovieIP(); model.FullPath = ipPath + @"Videos/Movies/" + movie.Filename; model.FullPathWebM = ipPath + @"Videos/Movies/" + movie.Id.ToString() + ".webm"; model.FullPathImage = ipPath + @"Videos/Films/" + movie.Id.ToString() + ".jpg"; //model.FullPath = ipPath + @"Videos/Movies/" + model.FileName; //model.FullPathWebM = ipPath + @"Videos/Movies/" + id.Value + ".webm"; //model.FullPathImage = ipPath + @"Videos/Films/" + id.Value + ".jpg"; //model.CategoryId = movie.CategoryId; model.MusicVideos = allMovies.Where(x => x.Id != movie.Id).Select(x => new MusicVideoModel { MovieName = x.Name, FullPath = GetFullPathIP(x.Id), FullPathWebM = GetFullPathWebmIP(x.Id), FullPathImage = GetFullPathImageIP(x.Id) }).ToList(); return(View(model)); }