public bool AddNewFilm() { if (PathToimage == null || PathToimage == "") { ErrorMessage = "*Не указано изображение"; return(false); } else if (FilmName == "" || AllActors == "" || AllGeners == "" || AllProdussers == "" || AllActors == null || AllGeners == null || AllProdussers == null) { ErrorMessage = "*Не заполнены все поля"; return(false); } FilmContent content = new FilmContent(); content.Image = File.ReadAllBytes(PathToimage); content.ImageName = PathToimage.Remove(0, PathToimage.LastIndexOf("\\") + 1); content.Actors = _actorsAtFilm.ToArray(); content.Description = DescriptionFilm; content.Geners = _genersAtFilm.ToArray(); content.Name = FilmName; content.Produsers = _produssersAtFilm.ToArray(); content.ReleaseDate = Date.ToString(); content.FilmTime = _hours + ":" + _minutes + ":" + _seconds; if (((UResult)_addNewFilm.AddNewFilm(content)) == UResult.FilmFailed) { ErrorMessage = "*Данный фильм уже существует"; return(false); } else { return(true); } }
public FilmContent GetFavoritFilms(int index) { FilmContent newFilm = new FilmContent(); using (var db = new FilmFinderDb()) { var favoritList = db.FavoritLists.ToArray().Where(i => i.User.Name == _currentUser.Login); var film = favoritList.ToArray()[index].Film; newFilm.Name = film.Name; newFilm.Description = film.Description; newFilm.ReleaseDate = film.ReleaseDate; var actors = db.ActorToFilms.ToArray().Where(i => i.Film == film).ToArray(); newFilm.Actors = new string[actors.Length]; for (int i = 0; i < actors.Length; i++) { newFilm.Actors[i] = actors[i].Actor.Name; } newFilm.IsFavorit = db.FavoritLists.ToList().Any(i => i.Film.Name == film.Name && i.User.Name == _currentUser.Login); //newFilm.Image = File.ReadAllBytes(film.Image); newFilm.FilmTime = film.TimeFilm; ///////////////// Bitmap btm = new Bitmap(film.Image); using (MemoryStream ms = new MemoryStream()) { btm.Save(ms, ImageFormat.Jpeg); btm.Dispose(); newFilm.Image = ms.GetBuffer(); } /////////////// var produssers = db.ProdusserToFilms.ToArray().Where(i => i.Film == film).ToArray(); newFilm.Produsers = new string[produssers.Length]; for (int i = 0; i < produssers.Length; i++) { newFilm.Produsers[i] = produssers[i].Producer.Name; } var genrs = db.GenreToFilms.ToArray().Where(i => i.Film == film).ToArray(); newFilm.Geners = new string[genrs.Length]; for (int i = 0; i < genrs.Length; i++) { newFilm.Geners[i] = genrs[i].Genre.Genr; } } return(newFilm); }
public int AddNewFilm(FilmContent content) { using (var db = new FilmFinderDb()) { if (db.Films.Any(i => i.Name == content.Name)) { return((int)UResult.FilmFailed); } } CreateNewFilm createNewFilm = new CreateNewFilm(content, _currentUser); createNewFilm.Create(); return((int)UResult.Access); }
public int AddNewFilm(FilmContent content) { return(_server.AddNewFilm(content)); }
public CreateNewFilm(FilmContent filmContent, CurrentUser currentUser) { _currentUser = currentUser; FilmContent = filmContent; _film = CreateFilmObject(); }