public void ShouldMapCorrectlyOnPersistanceModelToAggregateRoot()
        {
            var someData      = BuildSomeDataPersistanceModel();
            var aggregateRoot = SomeDataMapper.PersistanceModelToAggregateRoot(someData);

            Assert.Equal(aggregateRoot.CreationDate, someData.CreationDate);
            Assert.Equal(aggregateRoot.FacebookUrl.Value, someData.FacebookUrl);
            Assert.Equal(aggregateRoot.Color.Value, someData.Color);
            Assert.Equal(aggregateRoot.FirstName, someData.FirstName);
            Assert.Equal(aggregateRoot.Id, someData.Id);
            Assert.Equal(aggregateRoot.LastName, someData.LastName);
            Assert.Equal(aggregateRoot.MiddleName, someData.MiddleName);
            Assert.Equal(aggregateRoot.Title, someData.Title);
        }
 public List <SomeAggregate> GetSomeData(string userEmail)
 {
     try
     {
         using (var context = SomeDataEntities)
         {
             var businessUser     = context.BusinessUsers.FirstOrDefault(bu => bu.Identity.Email == userEmail);
             var mySampleSolution = context.SomeData
                                    .Where(k => k.BusinessUserId == businessUser.Id)
                                    .Select(k => SomeDataMapper.PersistanceModelToAggregateRoot(k)).ToList();
             return(mySampleSolution);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Exemple #3
0
 public SomeAggregate Get(Guid someDataId, SomeDataContext dbContext)
 {
     return(SomeDataMapper.PersistanceModelToAggregateRoot(
                dbContext.SomeData.FirstOrDefault(d => d.Id == someDataId)));
 }