public static bool AddNewSeason(SeriesSeason objSeries) { int lngLastSeason = 0; Media objMedia = null; IList items = Dal.GetInstance.GetSeries_SeasonsBySerieID(objSeries.SerieId); foreach (SeriesSeason item in items) { if (item.Season > lngLastSeason && item.IsDeleted != true) { lngLastSeason = item.Season; objMedia = item.Media; } } if (lngLastSeason > 0) { lngLastSeason++; if (objMedia != null) { SeriesSeason objSeason = new SeriesSeason(); objSeason.AddedDate = DateTime.Now; objSeason.Season = lngLastSeason; objSeason.Media = objMedia; objSeason.Title = objSeries.Title; objSeason.Publisher = objSeries.Publisher; objSeason.IsInProduction = objSeries.IsInProduction; objSeries.Country = objSeries.Country; objSeason.Description = objSeries.Description; objSeason.OfficialWebSite = objSeries.OfficialWebSite; objSeason.Runtime = objSeries.Runtime; objSeason.Rated = objSeries.Rated; objSeason.SerieId = objSeries.SerieId; Dal.GetInstance.AddSeriesSeason(objSeason); } return(true); } return(false); }
public static void Clean(SeriesSeason objItem) { foreach (Artist artist in objItem.Artists) { artist.IsOld = true; } foreach (Genre genre in objItem.Genres) { genre.IsOld = true; } foreach (Links link in objItem.Links) { link.IsOld = true; } foreach (Ressource ressource in objItem.Ressources) { ressource.IsOld = true; } objItem.Description = string.Empty; objItem.Publisher = null; objItem.Runtime = null; objItem.Rated = null; objItem.RemoveCover = true; objItem.Cover = null; objItem.BarCode = string.Empty; objItem.Comments = string.Empty; objItem.MyRating = null; objItem.ReleaseDate = null; objItem.IsComplete = false; objItem.TotalEpisodes = null; objItem.PublicRating = null; }
public static bool Fill(Hashtable objResults, SeriesSeason objEntity) { bool bAllfind = true; if (objResults != null) { #region Actors if (objResults.ContainsKey("Actors")) { ArtistServices.AddArtist((List <Artist>)objResults["Actors"], objEntity); } #endregion #region Audios if (objResults.ContainsKey("Audios")) { AudioServices.Add((List <Audio>)objResults["Audios"], objEntity); } #endregion #region Background if (objResults.ContainsKey("Background")) { if (objResults["Background"] != null) { RessourcesServices.AddBackground(Util.GetImage(objResults["Background"].ToString()), objEntity); } } #endregion #region Episodes if (objResults.ContainsKey("Episodes")) { if (objEntity.TotalEpisodes == null) { objEntity.TotalEpisodes = Convert.ToInt32(objResults["Episodes"]); } } #endregion #region Image int index; if (objResults.ContainsKey("Image")) { if (objResults["Image"] != null) { if (!string.IsNullOrWhiteSpace(objResults["Image"].ToString())) { byte[] objImage = Util.GetImage(objResults["Image"].ToString()); byte[] defaultCover = RessourcesServices.GetDefaultCover(objEntity, out index); if (objImage != null) { if (defaultCover == null || objEntity.RemoveCover == true || defaultCover.LongLength < objImage.LongLength) { if (objResults["Image"] != null) { RessourcesServices.AddImage(Util.GetImage(objResults["Image"].ToString()), objEntity, true); objEntity.RemoveCover = false; } } } } } } if (RessourcesServices.GetDefaultCover(objEntity, out index) == null) { bAllfind = false; } #endregion #region Publisher if (objResults.ContainsKey("Editor")) { bool isNew; if (objEntity.Publisher == null) { objEntity.Publisher = PublisherServices.GetPublisher((string)objResults["Editor"], out isNew, "Movie_Studio"); } } #endregion #region Comments if (objResults.ContainsKey("Comments")) { if (string.IsNullOrEmpty(objEntity.Comments) == true) { objEntity.Comments = objResults["Comments"].ToString().Trim(); } } #endregion #region Description if (objResults.ContainsKey("Description")) { if (string.IsNullOrEmpty(objEntity.Description) == true) { objEntity.Description = objResults["Description"].ToString().Trim(); } } if (string.IsNullOrEmpty(objEntity.Description) == true) { bAllfind = false; } #endregion #region Format if (objResults.ContainsKey("Format")) { if (objEntity.FileFormat == null) { objEntity.FileFormat = objResults["Format"] as FileFormat; } } #endregion #region DisplayAspectRatio if (objResults.ContainsKey("DisplayAspectRatio")) { if (objEntity.AspectRatio == null || objEntity.AspectRatio.IsOld == true || string.IsNullOrEmpty(objEntity.AspectRatio.Name)) { objEntity.AspectRatio = objResults["DisplayAspectRatio"] as AspectRatio; } } #endregion #region Genres if (objResults.ContainsKey("Types")) { GenreServices.AddGenres((List <string>)objResults["Types"], objEntity, false); } if (objEntity.Genres.Count == 0) { bAllfind = false; } #endregion #region Links if (objResults.ContainsKey("Links")) { LinksServices.AddLinks(objResults["Links"].ToString().Trim(), objEntity, false); } #region EditorLinks if (objResults.ContainsKey("EditorLinks")) { LinksServices.AddLinks(objResults["EditorLinks"].ToString().Trim(), objEntity, false); } #endregion #endregion #region Released Date if (objEntity.ReleaseDate == null) { if (objResults.ContainsKey("Released") == true) { DateTime objConverted; if (DateTime.TryParse(objResults["Released"].ToString().Trim(), out objConverted) == true) { objEntity.ReleaseDate = objConverted; } } } #endregion #region RunTime if (objResults.ContainsKey("Runtime")) { if (objEntity.Runtime == null) { objEntity.Runtime = Util.ParseRunTime(objResults["Runtime"].ToString()); } } if (objEntity.Runtime == null) { bAllfind = false; } #endregion #region Rating if (objResults.ContainsKey("Rating")) { if (objEntity.PublicRating == null) { float fltTemp; if (float.TryParse(objResults["Rating"].ToString().Trim(), out fltTemp)) { objEntity.PublicRating = Math.Round(fltTemp, 2); } else { string strTemp = objResults["Rating"].ToString().Trim().Replace('.', ','); if (float.TryParse(strTemp, out fltTemp)) { objEntity.PublicRating = Math.Round(fltTemp, 2); } } } } else if (objResults.ContainsKey("AlloCine")) { if (objEntity.PublicRating == null) { string[] strTemp = objResults["AlloCine"].ToString().Trim().Split("_".ToCharArray()); int lngTmp; if (strTemp.Count() >= 2) { if (int.TryParse(objResults["AlloCine"].ToString().Trim().Split("_".ToCharArray())[1], out lngTmp) == true) { objEntity.PublicRating = lngTmp * 5; } } else { if (int.TryParse(objResults["AlloCine"].ToString().Trim(), out lngTmp)) { objEntity.PublicRating = lngTmp * 5; } else if (objResults["AlloCine"].ToString().Trim().IndexOf(",", StringComparison.Ordinal) > -1) { string strNote = objResults["AlloCine"].ToString().Trim().Replace(',', '.'); if (int.TryParse(strNote, out lngTmp)) { objEntity.PublicRating = lngTmp * 5; } } } } } if (objEntity.PublicRating == null) { bAllfind = false; } #endregion #region Subs if (objResults.ContainsKey("Subs")) { SubTitleServices.Add((List <string>)objResults["Subs"], objEntity); } #endregion #region Title if (objResults.ContainsKey("Title") && string.IsNullOrWhiteSpace(objEntity.Title)) { objEntity.Title = objResults["Title"].ToString(); } if (string.IsNullOrWhiteSpace(objEntity.Title)) { bAllfind = false; } #endregion } else { bAllfind = false; } objEntity.IsComplete = bAllfind; return(bAllfind); }