private BandDB LogicToDB(Band band) { var bandDB = new BandDB(); bandDB.ID = band.ID; bandDB.Name = band.Name; bandDB.Description = band.Description; bandDB.InviteMessage = band.InviteMessage; if (band.Location != null) { bandDB.Latitude = (decimal)band.Location.Latitude; bandDB.Longitude = (decimal)band.Location.Longitude; } bandDB.ProfilePicture = band.ProfilePicture; bandDB.RowVersion = BitConverter.GetBytes(band.RowVersion); return(bandDB); }
private Band DBToLogic(BandDB bandDB) { var band = new Band(); if (bandDB != null) { band.ID = bandDB.ID; band.Name = bandDB.Name; band.Description = bandDB.Description; band.InviteMessage = bandDB.InviteMessage; if (bandDB.Latitude != null && bandDB.Longitude != null) { band.Location = new LatLng((double)bandDB.Latitude, (double)bandDB.Longitude); } band.ProfilePicture = bandDB.ProfilePicture; band.Genres = new List <Genre>(); foreach (var genre in bandDB.Genres) { band.Genres.Add(genreController.DBToLogic(genre)); } band.Applications = new List <Application>(); foreach (var application in bandDB.Applications) { band.Applications.Add(applicationController.DBToLogic(application)); } band.BandUsers = new List <BandUser>(); foreach (var bandUser in bandDB.BandUsers) { band.BandUsers.Add(bandUserController.DBToLogic(bandUser)); } band.RowVersion = BitConverter.ToInt64(bandDB.RowVersion, 0); return(band); } return(null); }