public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
 => new Response()
 {
     Commitments = await _context.Commitments
                   .Include(x => x.CommitmentFrequencies)
                   .Include("CommitmentFrequencies.Frequency")
                   .Include("CommitmentFrequencies.Frequency.FrequencyType")
                   .Where(x => x.ProfileId == request.ProfileId && x.CommitmentFrequencies.Any(f => f.Frequency.FrequencyType.Name == "per day"))
                   .Select(x => CommitmentApiModel.FromCommitment(x)).ToListAsync()
 };
Exemple #2
0
 public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
 => new Response()
 {
     Commitments = await _context.Commitments
                   .Include(x => x.Behaviour)
                   .Include("Behaviour.BehaviourType")
                   .Include(x => x.CommitmentFrequencies)
                   .Include("CommitmentFrequencies.Frequency")
                   .Include("CommitmentFrequencies.Frequency.FrequencyType")
                   .Select(x => CommitmentApiModel.FromCommitment(x)).ToListAsync()
 };
        public static CommitmentApiModel FromCommitment(Commitment commitment)
        {
            var model = new CommitmentApiModel();

            model.CommitmentId          = commitment.CommitmentId;
            model.BehaviourId           = commitment.BehaviourId;
            model.ProfileId             = commitment.ProfileId;
            model.CommitmentFrequencies = commitment.CommitmentFrequencies
                                          .Select(x => CommitmentFrequencyApiModel.FromCommitmentFrequency(x)).ToList();
            return(model);
        }
 public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
 => new Response()
 {
     Commitment = CommitmentApiModel.FromCommitment(await _context.Commitments.FindAsync(request.CommitmentId))
 };
Exemple #5
0
 public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
 => new Response()
 {
     Commitments = await _context.Commitments.Select(x => CommitmentApiModel.FromCommitment(x)).ToListAsync()
 };