initial commit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using Application.Common.Extensions;
|
||||
using AutoMapper;
|
||||
using Domain.Enums;
|
||||
using MediatR;
|
||||
|
||||
namespace Application.Features.CampaignManager.Queries;
|
||||
|
||||
public record GetClosingStatusListDto
|
||||
{
|
||||
public string? Id { get; init; }
|
||||
public string? Name { get; init; }
|
||||
}
|
||||
|
||||
public class GetClosingStatusListProfile : Profile
|
||||
{
|
||||
public GetClosingStatusListProfile()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class GetClosingStatusListResult
|
||||
{
|
||||
public List<GetClosingStatusListDto>? Data { get; init; }
|
||||
}
|
||||
|
||||
public class GetClosingStatusListRequest : IRequest<GetClosingStatusListResult>
|
||||
{
|
||||
}
|
||||
|
||||
public class GetClosingStatusListHandler : IRequestHandler<GetClosingStatusListRequest, GetClosingStatusListResult>
|
||||
{
|
||||
public GetClosingStatusListHandler()
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<GetClosingStatusListResult> Handle(GetClosingStatusListRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var statuses = Enum.GetValues(typeof(ClosingStatus))
|
||||
.Cast<ClosingStatus>()
|
||||
.Select(status => new GetClosingStatusListDto
|
||||
{
|
||||
Id = ((int)status).ToString(),
|
||||
Name = status.ToFriendlyName()
|
||||
})
|
||||
.ToList();
|
||||
|
||||
await Task.CompletedTask;
|
||||
|
||||
return new GetClosingStatusListResult
|
||||
{
|
||||
Data = statuses
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using Application.Common.CQS.Queries;
|
||||
using Application.Common.Extensions;
|
||||
using AutoMapper;
|
||||
using Domain.Entities;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Application.Features.LeadManager.Queries;
|
||||
|
||||
public record GetLeadByCampaignIdListDto
|
||||
{
|
||||
public string? Id { get; init; }
|
||||
public string? Number { get; init; }
|
||||
public string? Title { get; init; }
|
||||
public string? Description { get; init; }
|
||||
public string? CompanyName { get; init; }
|
||||
public string? CompanyAddressStreet { get; init; }
|
||||
public string? CompanyAddressCity { get; init; }
|
||||
public string? CompanyAddressState { get; init; }
|
||||
public string? CompanyPhoneNumber { get; init; }
|
||||
public string? CompanyEmail { get; init; }
|
||||
public DateTime? DateProspecting { get; init; }
|
||||
public DateTime? DateClosingEstimation { get; init; }
|
||||
public double? AmountTargeted { get; init; }
|
||||
public double? AmountClosed { get; init; }
|
||||
public double? BudgetScore { get; init; }
|
||||
public double? AuthorityScore { get; init; }
|
||||
public double? NeedScore { get; init; }
|
||||
public double? TimelineScore { get; init; }
|
||||
public string? PipelineStage { get; init; }
|
||||
public string? CampaignId { get; init; }
|
||||
public string? CampaignName { get; init; }
|
||||
public DateTime? CreatedAtUtc { get; init; }
|
||||
}
|
||||
|
||||
public class GetLeadByCampaignIdListProfile : Profile
|
||||
{
|
||||
public GetLeadByCampaignIdListProfile()
|
||||
{
|
||||
CreateMap<Lead, GetLeadByCampaignIdListDto>()
|
||||
.ForMember(
|
||||
dest => dest.CampaignName,
|
||||
opt => opt.MapFrom(src => src.Campaign != null ? src.Campaign.Title : string.Empty)
|
||||
)
|
||||
.ForMember(
|
||||
dest => dest.PipelineStage,
|
||||
opt => opt.MapFrom(src => src.PipelineStage.HasValue ? src.PipelineStage.Value.ToFriendlyName() : string.Empty)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public class GetLeadByCampaignIdListResult
|
||||
{
|
||||
public List<GetLeadByCampaignIdListDto>? Data { get; init; }
|
||||
}
|
||||
|
||||
public class GetLeadByCampaignIdListRequest : IRequest<GetLeadByCampaignIdListResult>
|
||||
{
|
||||
public string? CampaignId { get; init; }
|
||||
}
|
||||
|
||||
public class GetLeadByCampaignIdListHandler : IRequestHandler<GetLeadByCampaignIdListRequest, GetLeadByCampaignIdListResult>
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IQueryContext _context;
|
||||
|
||||
public GetLeadByCampaignIdListHandler(IMapper mapper, IQueryContext context)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetLeadByCampaignIdListResult> Handle(GetLeadByCampaignIdListRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var query = _context
|
||||
.Lead
|
||||
.AsNoTracking()
|
||||
.IsDeletedEqualTo(false)
|
||||
.Include(x => x.Campaign)
|
||||
.Where(x => x.CampaignId == request.CampaignId)
|
||||
.AsQueryable();
|
||||
|
||||
var entities = await query.ToListAsync(cancellationToken);
|
||||
|
||||
var dtos = _mapper.Map<List<GetLeadByCampaignIdListDto>>(entities);
|
||||
|
||||
return new GetLeadByCampaignIdListResult
|
||||
{
|
||||
Data = dtos
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
using Application.Common.CQS.Queries;
|
||||
using Application.Common.Extensions;
|
||||
using AutoMapper;
|
||||
using Domain.Entities;
|
||||
using Domain.Enums;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Application.Features.LeadManager.Queries;
|
||||
|
||||
public record GetLeadListDto
|
||||
{
|
||||
public string? Id { get; init; }
|
||||
public string? Number { get; init; }
|
||||
public string? Title { get; init; }
|
||||
public string? Description { get; init; }
|
||||
public string? CompanyName { get; init; }
|
||||
public string? CompanyDescription { get; init; }
|
||||
public string? CompanyAddressStreet { get; init; }
|
||||
public string? CompanyAddressCity { get; init; }
|
||||
public string? CompanyAddressState { get; init; }
|
||||
public string? CompanyAddressZipCode { get; init; }
|
||||
public string? CompanyAddressCountry { get; init; }
|
||||
public string? CompanyPhoneNumber { get; init; }
|
||||
public string? CompanyFaxNumber { get; init; }
|
||||
public string? CompanyEmail { get; init; }
|
||||
public string? CompanyWebsite { get; init; }
|
||||
public string? CompanyWhatsApp { get; init; }
|
||||
public string? CompanyLinkedIn { get; init; }
|
||||
public string? CompanyFacebook { get; init; }
|
||||
public string? CompanyInstagram { get; init; }
|
||||
public string? CompanyTwitter { get; init; }
|
||||
public DateTime? DateProspecting { get; init; }
|
||||
public DateTime? DateClosingEstimation { get; init; }
|
||||
public DateTime? DateClosingActual { get; init; }
|
||||
public double? AmountTargeted { get; init; }
|
||||
public double? AmountClosed { get; init; }
|
||||
public double? BudgetScore { get; init; }
|
||||
public double? AuthorityScore { get; init; }
|
||||
public double? NeedScore { get; init; }
|
||||
public double? TimelineScore { get; init; }
|
||||
public PipelineStage? PipelineStage { get; init; }
|
||||
public string? PipelineStageName { get; init; }
|
||||
public ClosingStatus? ClosingStatus { get; init; }
|
||||
public string? ClosingStatusName { get; init; }
|
||||
public string? ClosingNote { get; init; }
|
||||
public string? CampaignId { get; init; }
|
||||
public Campaign? Campaign { get; init; }
|
||||
public string? CampaignName { get; init; }
|
||||
public string? SalesTeamId { get; init; }
|
||||
public string? SalesTeamName { get; init; }
|
||||
public DateTime? CreatedAtUtc { get; init; }
|
||||
}
|
||||
|
||||
public class GetLeadListProfile : Profile
|
||||
{
|
||||
public GetLeadListProfile()
|
||||
{
|
||||
CreateMap<Lead, GetLeadListDto>()
|
||||
.ForMember(
|
||||
dest => dest.CampaignName,
|
||||
opt => opt.MapFrom(src => src.Campaign != null ? src.Campaign.Title : string.Empty)
|
||||
)
|
||||
.ForMember(
|
||||
dest => dest.PipelineStageName,
|
||||
opt => opt.MapFrom(src => src.PipelineStage.HasValue ? src.PipelineStage.Value.ToFriendlyName() : string.Empty)
|
||||
)
|
||||
.ForMember(
|
||||
dest => dest.ClosingStatusName,
|
||||
opt => opt.MapFrom(src => src.ClosingStatus.HasValue ? src.ClosingStatus.Value.ToFriendlyName() : string.Empty)
|
||||
)
|
||||
.ForMember(
|
||||
dest => dest.SalesTeamName,
|
||||
opt => opt.MapFrom(src => src.SalesTeam != null ? src.SalesTeam.Name : string.Empty)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public class GetLeadListResult
|
||||
{
|
||||
public List<GetLeadListDto>? Data { get; init; }
|
||||
}
|
||||
|
||||
public class GetLeadListRequest : IRequest<GetLeadListResult>
|
||||
{
|
||||
public bool IsDeleted { get; init; } = false;
|
||||
}
|
||||
|
||||
public class GetLeadListHandler : IRequestHandler<GetLeadListRequest, GetLeadListResult>
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IQueryContext _context;
|
||||
|
||||
public GetLeadListHandler(IMapper mapper, IQueryContext context)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetLeadListResult> Handle(GetLeadListRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var query = _context
|
||||
.Lead
|
||||
.AsNoTracking()
|
||||
.IsDeletedEqualTo(request.IsDeleted)
|
||||
.Include(x => x.Campaign)
|
||||
.Include(x => x.SalesTeam)
|
||||
.AsQueryable();
|
||||
|
||||
var entities = await query.ToListAsync(cancellationToken);
|
||||
|
||||
var dtos = _mapper.Map<List<GetLeadListDto>>(entities);
|
||||
|
||||
return new GetLeadListResult
|
||||
{
|
||||
Data = dtos
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using Application.Common.CQS.Queries;
|
||||
using AutoMapper;
|
||||
using Domain.Entities;
|
||||
using FluentValidation;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Application.Features.LeadManager.Queries;
|
||||
|
||||
public class GetLeadSingleProfile : Profile
|
||||
{
|
||||
public GetLeadSingleProfile()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class GetLeadSingleResult
|
||||
{
|
||||
public Lead? Data { get; init; }
|
||||
}
|
||||
|
||||
public class GetLeadSingleRequest : IRequest<GetLeadSingleResult>
|
||||
{
|
||||
public string? Id { get; init; }
|
||||
}
|
||||
|
||||
public class GetLeadSingleValidator : AbstractValidator<GetLeadSingleRequest>
|
||||
{
|
||||
public GetLeadSingleValidator()
|
||||
{
|
||||
RuleFor(x => x.Id).NotEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
public class GetLeadSingleHandler : IRequestHandler<GetLeadSingleRequest, GetLeadSingleResult>
|
||||
{
|
||||
private readonly IQueryContext _context;
|
||||
|
||||
public GetLeadSingleHandler(
|
||||
IQueryContext context
|
||||
)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetLeadSingleResult> Handle(GetLeadSingleRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var query = _context
|
||||
.Lead
|
||||
.AsNoTracking()
|
||||
.Include(x => x.Campaign)
|
||||
.Include(x => x.LeadContacts)
|
||||
.Include(x => x.LeadActivities)
|
||||
.Where(x => x.Id == request.Id)
|
||||
.AsQueryable();
|
||||
|
||||
var entity = await query.SingleOrDefaultAsync(cancellationToken);
|
||||
|
||||
return new GetLeadSingleResult
|
||||
{
|
||||
Data = entity
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using Application.Common.Extensions;
|
||||
using AutoMapper;
|
||||
using Domain.Enums;
|
||||
using MediatR;
|
||||
|
||||
namespace Application.Features.CampaignManager.Queries;
|
||||
|
||||
public record GetPipelineStageListDto
|
||||
{
|
||||
public string? Id { get; init; }
|
||||
public string? Name { get; init; }
|
||||
}
|
||||
|
||||
public class GetPipelineStageListProfile : Profile
|
||||
{
|
||||
public GetPipelineStageListProfile()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class GetPipelineStageListResult
|
||||
{
|
||||
public List<GetPipelineStageListDto>? Data { get; init; }
|
||||
}
|
||||
|
||||
public class GetPipelineStageListRequest : IRequest<GetPipelineStageListResult>
|
||||
{
|
||||
}
|
||||
|
||||
public class GetPipelineStageListHandler : IRequestHandler<GetPipelineStageListRequest, GetPipelineStageListResult>
|
||||
{
|
||||
public GetPipelineStageListHandler()
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<GetPipelineStageListResult> Handle(GetPipelineStageListRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var statuses = Enum.GetValues(typeof(PipelineStage))
|
||||
.Cast<PipelineStage>()
|
||||
.Select(status => new GetPipelineStageListDto
|
||||
{
|
||||
Id = ((int)status).ToString(),
|
||||
Name = status.ToFriendlyName()
|
||||
})
|
||||
.ToList();
|
||||
|
||||
await Task.CompletedTask;
|
||||
|
||||
return new GetPipelineStageListResult
|
||||
{
|
||||
Data = statuses
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user