예제 #1
0
            public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
            {
                var profileId = new Guid(_httpContextAccessor.HttpContext.User
                                         .FindFirst(Constants.ClaimTypes.ProfileId).Value);

                var profile = await _context.FindAsync <Profile>(profileId);

                var dashboard = await _context.FindAsync <Dashboard>(profile.DefaultDashboardId.Value);

                return(new Response()
                {
                    Dashboard = dashboard.ToDto()
                });
            }
예제 #2
0
            public async Task <Unit> Handle(Request request, CancellationToken cancellationToken)
            {
                var photographer = await _context.FindAsync <Photographer>(request.PhotographerId);

                var company = request.Company.CompanyId != default
                    ? await _context.FindAsync <Company>(request.Company.CompanyId)
                    : new Company();

                photographer.AddCompany(company.CompanyId);

                _context.Add(photographer);

                _context.Add(company);

                await _context.SaveChangesAsync(cancellationToken);

                return(new Unit {
                });
            }
예제 #3
0
            public async Task <Unit> Handle(Request request, CancellationToken cancellationToken)
            {
                var task = await _context.FindAsync <DblDip.Core.Models.Task>(request.TaskId);

                task.Complete(_dateTime.UtcNow);

                _context.Add(task);

                await _context.SaveChangesAsync(cancellationToken);

                return(new());
            }
예제 #4
0
            public async Task <ResponseBase> Handle(Request request, CancellationToken cancellationToken)
            {
                var user = await _context.FindAsync <User>(new Guid(_httpContextAccessor.HttpContext.User.FindFirst(Constants.ClaimTypes.UserId).Value));

                var profile = await _context.FindAsync <Profile>(request.ProfileId);

                var account = await _context.FindAsync <Account>(profile.AccountId);

                if (account.UserId != user.UserId)
                {
                    throw new Exception("Security Exception");
                }

                account.SetDefaultProfileId(request.ProfileId);

                _context.Add(account);

                await _context.SaveChangesAsync(cancellationToken);

                return(new ());
            }
예제 #5
0
            public async Task <Unit> Handle(Request request, CancellationToken cancellationToken)
            {
                var consultation = await _context.FindAsync <Consultation>(request.ConsultationId);

                consultation.Complete(_dateTime.UtcNow);

                _context.Add(consultation);

                await _context.SaveChangesAsync(cancellationToken);

                return(new());
            }
예제 #6
0
            public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
            {
                var photographer = await _context.FindAsync <Photographer>(request.PhotographerId);

                var digitalAsset = (await DigitalAsset.Upload(_httpContextAccessor, _context, cancellationToken)).Single();

                photographer.UpdateAvatar(digitalAsset.DigitalAssetId);

                await _context.SaveChangesAsync(cancellationToken);

                return(new Response()
                {
                    DigitalAssetId = digitalAsset.DigitalAssetId
                });
            }
예제 #7
0
        private async Task <IAggregateRoot> GetAggregateAsync(Type type, Guid streamId)
        {
            var aggregate = _inMemoryAggregates.SingleOrDefault(x => x.Key == streamId).Value;

            aggregate ??= (await _context.FindAsync(type, streamId)) as IAggregateRoot;

            if (aggregate == null)
            {
                aggregate = GetUninitializedObject(type) as IAggregateRoot;

                _ = _context.Add(aggregate);
            }

            if (!_inMemoryAggregates.Any(x => x.Key == streamId))
            {
                _inMemoryAggregates.Add(streamId, aggregate);
            }

            return(aggregate);
        }
예제 #8
0
            public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
            {
                var user = _context.Set <User>().Where(x => x.Username == request.Email).SingleOrDefault();

                if (user != null)
                {
                    return(null);
                }

                var quote = await _context.FindAsync <Quote>(request.QuoteId);

                if (quote == null || quote.Declined.HasValue || quote.Accepted.HasValue)
                {
                    return(null);
                }

                return(new Response(_tokenProvider.Get(request.Email,
                                                       new List <Claim> {
                    new Claim(Core.Constants.ClaimTypes.Role, nameof(Core.Constants.Roles.Lead))
                })));
            }