Beispiel #1
0
        /// <summary>
        /// Updates the without email and password.
        /// </summary>
        /// <param name="customer">The customer.</param>
        /// <exception cref="NotImplementedException"></exception>
        public void UpdateWithoutEmailAndPassword(Customer customer)
        {
            var customerEntry = FrederickContext.Entry(customer);

            customerEntry.Property("FirstName").IsModified = true;
            customerEntry.Property("LastName").IsModified  = true;
            customerEntry.Property("CountryId").IsModified = true;
        }
Beispiel #2
0
        /// <summary>
        /// dispatch domain events as an asynchronous operation.
        /// </summary>
        /// <param name="mediator">The mediator.</param>
        /// <param name="ctx">The CTX.</param>
        /// <returns>Task.</returns>
        public static async Task DispatchDomainEventsAsync(this IMediator mediator, FrederickContext ctx)
        {
            var domainEntities = ctx.ChangeTracker
                                 .Entries <Entity>()
                                 .Where(x => x.Entity.DomainEvents != null && x.Entity.DomainEvents.Any());

            var domainEvents = domainEntities.SelectMany(x => x.Entity.DomainEvents).ToList();

            domainEntities.ToList().ForEach(entity => entity.Entity.DomainEvents.Clear());

            var tasks = domainEvents.Select(async(domainEvent) =>
            {
                await mediator.Publish(domainEvent);
            });

            await Task.WhenAll(tasks);
        }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductRepository"/> class.
 /// </summary>
 /// <param name="dbContext">The database context.</param>
 public ProductRepository(FrederickContext dbContext)
     : base(dbContext)
 {
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EfRepository{T}"/> class.
 /// </summary>
 /// <param name="dbContext">The database context.</param>
 public EfRepository(FrederickContext dbContext)
 {
     FrederickContext = dbContext;
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnitOfWork"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 public UnitOfWork(FrederickContext context)
 {
     _frederickContext = context;
 }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CustomerRepository"/> class.
 /// </summary>
 /// <param name="dbContext">The database context.</param>
 public CustomerRepository(FrederickContext dbContext)
     : base(dbContext)
 {
 }
Beispiel #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UnitOfWork" /> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="mediator">The mediator.</param>
 public UnitOfWork(FrederickContext context, IMediator mediator)
 {
     _frederickContext = context;
     _mediator         = mediator;
 }