/// <summary> /// Convert the map contract to an entity object. /// </summary> /// <param name="source">The source.</param> /// <returns>The entity object</returns> public static Map ToEntity(this Contract.Data.Map.Map source) { return(new Map { Id = source.Id, Name = source.Name, IsPlayable = source.IsPlayable, Windows = source.Windows.Select(window => window.ToEntity()).ToList() }); }
/// <summary> /// To the entity. /// </summary> /// <param name="source">The source.</param> /// <returns>Map entity instance</returns> public static Map ToEntity(this Contract.Data.Map.Map source) { return(new Map { Id = source.Id, Name = source.Name, IsPlayable = source.IsPlayable, Windows = source.Windows.ToList(), NumberOfWindows = source.Windows.Count, NumberOfHoles = source.Windows.Sum(window => window.Holes.Count) }); }
/// <summary> /// Converts the map contract to the corresponding entity /// </summary> /// <param name="contractMap">The contract map.</param> /// <param name="visibleWindows">The visible windows.</param> /// <returns> /// The entity /// </returns> public static Map ToEntity(this Contract.Data.Map.Map contractMap, IEnumerable <long> visibleWindows) { var map = new Map { Id = contractMap.Id, Name = contractMap.Name }; var ownedWindows = visibleWindows as long[] ?? visibleWindows.ToArray(); foreach (var contractWindow in contractMap.Windows) { var entityWindow = ToEntity(contractWindow); entityWindow.IsOwnWindow = ownedWindows.Contains(entityWindow.Id); map.Windows.Add(entityWindow); } return(map); }
/// <summary> /// Converts the map contract to the corresponding entity /// </summary> /// <param name="contractMap">The contract map.</param> /// <returns> /// The entity /// </returns> public static Map ToEntity(this Contract.Data.Map.Map contractMap) { return(ToEntity(contractMap, Enumerable.Empty <long>())); }