Added IHasBudget

This commit is contained in:
Luke Pulverenti 2013-12-02 11:16:03 -05:00
parent 44b2ec2093
commit 317f411070
13 changed files with 116 additions and 39 deletions

View File

@ -248,8 +248,12 @@ namespace MediaBrowser.Api
item.ForcedSortName = request.SortName;
}
item.Budget = request.Budget;
item.Revenue = request.Revenue;
var hasBudget = item as IHasBudget;
if (hasBudget != null)
{
hasBudget.Budget = request.Budget;
hasBudget.Revenue = request.Revenue;
}
var hasCriticRating = item as IHasCriticRating;
if (hasCriticRating != null)

View File

@ -86,24 +86,12 @@ namespace MediaBrowser.Controller.Entities
/// <value>The id.</value>
public Guid Id { get; set; }
/// <summary>
/// Gets or sets the budget.
/// </summary>
/// <value>The budget.</value>
public double? Budget { get; set; }
/// <summary>
/// Gets or sets the taglines.
/// </summary>
/// <value>The taglines.</value>
public List<string> Taglines { get; set; }
/// <summary>
/// Gets or sets the revenue.
/// </summary>
/// <value>The revenue.</value>
public double? Revenue { get; set; }
/// <summary>
/// Gets or sets the trailer URL.
/// </summary>

View File

@ -0,0 +1,18 @@

namespace MediaBrowser.Controller.Entities
{
public interface IHasBudget
{
/// <summary>
/// Gets or sets the budget.
/// </summary>
/// <value>The budget.</value>
double? Budget { get; set; }
/// <summary>
/// Gets or sets the revenue.
/// </summary>
/// <value>The revenue.</value>
double? Revenue { get; set; }
}
}

View File

@ -11,7 +11,7 @@ namespace MediaBrowser.Controller.Entities.Movies
/// <summary>
/// Class Movie
/// </summary>
public class Movie : Video, IHasCriticRating, IHasSoundtracks
public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasBudget
{
public List<Guid> SpecialFeatureIds { get; set; }
@ -23,6 +23,18 @@ namespace MediaBrowser.Controller.Entities.Movies
SoundtrackIds = new List<Guid>();
}
/// <summary>
/// Gets or sets the budget.
/// </summary>
/// <value>The budget.</value>
public double? Budget { get; set; }
/// <summary>
/// Gets or sets the revenue.
/// </summary>
/// <value>The revenue.</value>
public double? Revenue { get; set; }
/// <summary>
/// Gets or sets the critic rating.
/// </summary>

View File

@ -4,7 +4,7 @@ using System;
namespace MediaBrowser.Controller.Entities
{
public class MusicVideo : Video, IHasArtist, IHasMusicGenres
public class MusicVideo : Video, IHasArtist, IHasMusicGenres, IHasBudget
{
/// <summary>
/// Gets or sets the artist.
@ -18,6 +18,18 @@ namespace MediaBrowser.Controller.Entities
/// <value>The album.</value>
public string Album { get; set; }
/// <summary>
/// Gets or sets the budget.
/// </summary>
/// <value>The budget.</value>
public double? Budget { get; set; }
/// <summary>
/// Gets or sets the revenue.
/// </summary>
/// <value>The revenue.</value>
public double? Revenue { get; set; }
/// <summary>
/// Determines whether the specified name has artist.
/// </summary>

View File

@ -8,7 +8,7 @@ namespace MediaBrowser.Controller.Entities
/// <summary>
/// Class Trailer
/// </summary>
public class Trailer : Video, IHasCriticRating, IHasSoundtracks
public class Trailer : Video, IHasCriticRating, IHasSoundtracks, IHasBudget
{
public List<Guid> SoundtrackIds { get; set; }
@ -19,6 +19,18 @@ namespace MediaBrowser.Controller.Entities
SoundtrackIds = new List<Guid>();
}
/// <summary>
/// Gets or sets the budget.
/// </summary>
/// <value>The budget.</value>
public double? Budget { get; set; }
/// <summary>
/// Gets or sets the revenue.
/// </summary>
/// <value>The revenue.</value>
public double? Revenue { get; set; }
/// <summary>
/// Gets or sets the critic rating.
/// </summary>

View File

@ -90,6 +90,7 @@
<Compile Include="Entities\GameSystem.cs" />
<Compile Include="Entities\IByReferenceItem.cs" />
<Compile Include="Entities\IHasAspectRatio.cs" />
<Compile Include="Entities\IHasBudget.cs" />
<Compile Include="Entities\IHasCriticRating.cs" />
<Compile Include="Entities\IHasSoundtracks.cs" />
<Compile Include="Entities\IItemByName.cs" />

View File

@ -162,10 +162,14 @@ namespace MediaBrowser.Controller.Providers
case "Budget":
{
var text = reader.ReadElementContentAsString();
double value;
if (double.TryParse(text, NumberStyles.Any, _usCulture, out value))
var hasBudget = item as IHasBudget;
if (hasBudget != null)
{
item.Budget = value;
double value;
if (double.TryParse(text, NumberStyles.Any, _usCulture, out value))
{
hasBudget.Budget = value;
}
}
break;
@ -174,10 +178,14 @@ namespace MediaBrowser.Controller.Providers
case "Revenue":
{
var text = reader.ReadElementContentAsString();
double value;
if (double.TryParse(text, NumberStyles.Any, _usCulture, out value))
var hasBudget = item as IHasBudget;
if (hasBudget != null)
{
item.Revenue = value;
double value;
if (double.TryParse(text, NumberStyles.Any, _usCulture, out value))
{
hasBudget.Revenue = value;
}
}
break;

View File

@ -701,8 +701,12 @@ namespace MediaBrowser.Providers.Movies
}
movie.HomePageUrl = movieData.homepage;
movie.Budget = movieData.budget;
movie.Revenue = movieData.revenue;
var hasBudget = movie as IHasBudget;
if (hasBudget != null)
{
hasBudget.Budget = movieData.budget;
hasBudget.Revenue = movieData.revenue;
}
if (!string.IsNullOrEmpty(movieData.tagline))
{

View File

@ -280,14 +280,18 @@ namespace MediaBrowser.Providers.Savers
builder.Append("</Trailers>");
}
if (item.Budget.HasValue)
var hasBudget = item as IHasBudget;
if (hasBudget != null)
{
builder.Append("<Budget>" + SecurityElement.Escape(item.Budget.Value.ToString(UsCulture)) + "</Budget>");
}
if (hasBudget.Budget.HasValue)
{
builder.Append("<Budget>" + SecurityElement.Escape(hasBudget.Budget.Value.ToString(UsCulture)) + "</Budget>");
}
if (item.Revenue.HasValue)
{
builder.Append("<Revenue>" + SecurityElement.Escape(item.Revenue.Value.ToString(UsCulture)) + "</Revenue>");
if (hasBudget.Revenue.HasValue)
{
builder.Append("<Revenue>" + SecurityElement.Escape(hasBudget.Revenue.Value.ToString(UsCulture)) + "</Revenue>");
}
}
if (item.CommunityRating.HasValue)

View File

@ -727,14 +727,18 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.EnableInternetProviders = !item.DontFetchMeta;
}
if (fields.Contains(ItemFields.Budget))
var hasBudget = item as IHasBudget;
if (hasBudget != null)
{
dto.Budget = item.Budget;
}
if (fields.Contains(ItemFields.Budget))
{
dto.Budget = hasBudget.Budget;
}
if (fields.Contains(ItemFields.Revenue))
{
dto.Revenue = item.Revenue;
if (fields.Contains(ItemFields.Revenue))
{
dto.Revenue = hasBudget.Revenue;
}
}
dto.EndDate = item.EndDate;

View File

@ -19,7 +19,12 @@ namespace MediaBrowser.Server.Implementations.Sorting
private double GetValue(BaseItem x)
{
return x.Budget ?? 0;
var hasBudget = x as IHasBudget;
if (hasBudget != null)
{
return hasBudget.Budget ?? 0;
}
return 0;
}
/// <summary>

View File

@ -19,7 +19,12 @@ namespace MediaBrowser.Server.Implementations.Sorting
private double GetValue(BaseItem x)
{
return x.Revenue ?? 0;
var hasBudget = x as IHasBudget;
if (hasBudget != null)
{
return hasBudget.Revenue ?? 0;
}
return 0;
}
/// <summary>