public async Task <Guid> InsertAsync(Profile profile) { var entity = new ProfileEntity { Id = profile.Id, FirstName = profile.FirstName, LastName = profile.LastName, Gender = profile.Gender, DateOfBirth = profile.DateOfBirth?.ToUnixTimeMilliseconds(), City = profile.City }; await context.Profiles.InsertOneAsync(entity); return(entity.Id); }
private static Profile ToDomain(ProfileEntity entity) { DateTimeOffset?dateOfBirth = null; if (entity.DateOfBirth.HasValue) { dateOfBirth = DateTimeOffset.FromUnixTimeMilliseconds(entity.DateOfBirth.Value); } return(new Profile( entity.Id, entity.FirstName, entity.LastName, entity.Gender, dateOfBirth, entity.City, entity.ProfilePicture)); }