/// <summary> /// Converts a entity GeocacheItem into a GeocacheItemModel /// </summary> /// <param name="geocacheItem">The entity geocache item.</param> /// <returns>GeocacheItemModel of the converted geocache item.</returns> public static IGeocacheItemModel ConvertFromGeocacheItem(GeocacheItem geocacheItem) { var newGeocacheItem = new GeocacheItemModel(); newGeocacheItem.Id = geocacheItem.Id; newGeocacheItem.Name = geocacheItem.Name; newGeocacheItem.GeocacheId = geocacheItem.GeocacheId; newGeocacheItem.ActiveStartDate = geocacheItem.ActiveStartDate; newGeocacheItem.ActiveEndDate = geocacheItem.ActiveEndDate; return(newGeocacheItem); }
public static async Task <GeocacheItem> CreateGeocacheItem(geocachingContext db, IGeocacheItemModel geocacheItem) { var createdItem = await Task.Run(() => { var newGeocacheItem = new GeocacheItem { Id = geocacheItem.Id, Name = geocacheItem.Name, GeocacheId = geocacheItem.GeocacheId, ActiveStartDate = geocacheItem.ActiveStartDate, ActiveEndDate = geocacheItem.ActiveEndDate }; db.GeocacheItem.Add(newGeocacheItem); db.SaveChanges(); return(newGeocacheItem); }); return(createdItem); }