public UserMongoMap GetMongoMap(User userData) { if (userData == null) { throw new ArgumentNullException("userData"); } if (string.IsNullOrEmpty(userData.Id)) { this.IsNew = true; this.Id = ObjectId.GenerateNewId(); } else { this.Id = new ObjectId(userData.Id); } this.Name = userData.Name; this.Email = userData.Email; if (userData.ServicesList != null) { this.ServicesList = new List <ServiceMongoMap>(); foreach (var item in userData.ServicesList) { var service = new ServiceMongoMap().GetMongoMap(item); if (service == null) { continue; } this.ServicesList.Add(service); } } this.Status = userData.Status.GetUserStatusEnumStringValue(); this.CreationTime = userData.CreateTime; return(this); }
public UserMongoMap GetMongoMap(User userData) { if (userData == null) throw new ArgumentNullException("userData"); if (string.IsNullOrEmpty(userData.Id)) { this.IsNew = true; this.Id = ObjectId.GenerateNewId(); } else this.Id = new ObjectId(userData.Id); this.Name = userData.Name; this.Email = userData.Email; if (userData.ServicesList != null) { this.ServicesList = new List<ServiceMongoMap>(); foreach (var item in userData.ServicesList) { var service = new ServiceMongoMap().GetMongoMap(item); if(service == null) continue; this.ServicesList.Add(service); } } this.Status = userData.Status.GetUserStatusEnumStringValue(); this.CreationTime = userData.CreateTime; return this; }