vgquotes/Src/VideoGameQuotes.Api/GamingSystem.cs

50 lines
1.3 KiB
C#
Raw Normal View History

2011-02-09 00:05:32 +00:00
using System;
2011-02-27 08:47:16 +00:00
using JetBrains.Annotations;
2011-02-09 00:05:32 +00:00
using Portoa.Persistence;
namespace VideoGameQuotes.Api {
public class GamingSystem : Entity<GamingSystem, int>, IDtoMappable<SystemDto> {
public GamingSystem() {
Created = DateTime.UtcNow;
}
2011-02-09 00:05:32 +00:00
public virtual DateTime Created { get; set; }
public virtual DateTime ReleaseDate { get; set; }
public virtual string Name { get; set; }
public virtual string Abbreviation { get; set; }
2011-02-27 08:47:16 +00:00
[CanBeNull]
public virtual byte[] Icon { get; set; }
public virtual SystemDto ToDto() {
return new SystemDto {
Id = Id,
Created = Created,
ReleaseDate = ReleaseDate,
Name = Name,
2011-02-27 08:47:16 +00:00
Icon = Icon != null ? Convert.ToBase64String(Icon) : null,
Abbreviation = Abbreviation
};
}
}
public class SystemDto {
public int Id { get; set; }
public DateTime Created { get; set; }
public DateTime ReleaseDate { get; set; }
public string Name { get; set; }
public string Abbreviation { get; set; }
2011-02-27 08:47:16 +00:00
[CanBeNull]
public string Icon { get; set; }
}
public static class SystemExtensions {
[CanBeNull]
public static string GetBase64EncodedIcon(this GamingSystem system) {
if (system.Icon == null || system.Icon.Length == 0) {
return null;
}
return Convert.ToBase64String(system.Icon);
}
2011-02-09 00:05:32 +00:00
}
}