-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from machariamwangi/feature/backend-dashboard…
…-admin-app Feature/backend dashboard admin app
- Loading branch information
Showing
60 changed files
with
2,847 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
backend/src/mms.Application/MentorManagers/Query/GetMentorManagersCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using AspNetCoreHero.Results; | ||
using MediatR; | ||
|
||
namespace mms.Application.MentorManagers.Query | ||
{ | ||
public class GetMentorManagersCommand : IRequest<IResult<List<GetMentorManagersResponse>>> | ||
{ | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
backend/src/mms.Application/MentorManagers/Query/GetMentorManagersCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using AspNetCoreHero.Results; | ||
using AutoMapper; | ||
using MediatR; | ||
using Microsoft.EntityFrameworkCore; | ||
using mms.Infrastructure.Context; | ||
using mms.Infrastructure.Interface; | ||
|
||
namespace mms.Application.MentorManagers.Query | ||
{ | ||
public class GetMentorManagersCommandHandler : IRequestHandler<GetMentorManagersCommand, | ||
IResult<List<GetMentorManagersResponse>>> | ||
{ | ||
private readonly ICurrentUserService _currentUserService; | ||
private readonly ApplicationContext _context; | ||
private readonly IMapper _mapper; | ||
|
||
public GetMentorManagersCommandHandler(ICurrentUserService currentUserService, ApplicationContext context, | ||
IMapper mapper) | ||
{ | ||
_currentUserService = currentUserService; | ||
_context = context; | ||
_mapper = mapper; | ||
} | ||
|
||
|
||
public async Task<IResult<List<GetMentorManagersResponse>>> Handle(GetMentorManagersCommand request, | ||
CancellationToken cancellationToken) | ||
{ | ||
if (string.IsNullOrEmpty(_currentUserService.AppUserId)) | ||
{ | ||
return await Result<List<GetMentorManagersResponse>>.FailAsync("Invalid user"); | ||
} | ||
|
||
var mentors = await _context.MentorManagers.Include(M => M.ProgramsMentors).Include(y => y.Programmes).Include(x => x.AppUser).Where(x => x.AppUserId == _currentUserService.AppUserId).ToListAsync(); | ||
if (mentors == null) | ||
{ | ||
return await Result<List<GetMentorManagersResponse>>.FailAsync("No Mentor Managers Available"); | ||
} | ||
|
||
var result = _mapper.Map<List<GetMentorManagersResponse>>(mentors); | ||
|
||
return await Result<List<GetMentorManagersResponse>>.SuccessAsync(result); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
backend/src/mms.Application/MentorManagers/Query/GetMentorManagersResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using mms.Domain.Entities; | ||
using ProgrammeEntity = mms.Domain.Entities.Programme; | ||
|
||
namespace mms.Application.MentorManagers.Query | ||
{ | ||
public class GetMentorManagersResponse | ||
{ | ||
public string ProgramsMentorId { get; set; } | ||
public string AppUserId { get; set; } | ||
public string ProgramId { get; set; } | ||
public ProgramsMentor ProgramsMentor { get; set; } | ||
public ProgrammeEntity Programme { get; set; } | ||
public AppUser AppUser { get; set; } | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
backend/src/mms.Application/Mentors/Query/GetMentorsCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using AspNetCoreHero.Results; | ||
using MediatR; | ||
|
||
namespace mms.Application.Mentors.Query | ||
{ | ||
public class GetMentorsCommand : IRequest<IResult<List<GetMentorsResponse>>> | ||
{ | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
backend/src/mms.Application/Mentors/Query/GetMentorsCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using AspNetCoreHero.Results; | ||
using AutoMapper; | ||
using MediatR; | ||
using Microsoft.EntityFrameworkCore; | ||
using mms.Infrastructure.Context; | ||
using mms.Infrastructure.Interface; | ||
|
||
namespace mms.Application.Mentors.Query | ||
{ | ||
public class GetMentorsCommandHandler : IRequestHandler<GetMentorsCommand, | ||
IResult<List<GetMentorsResponse>>> | ||
{ | ||
private readonly ICurrentUserService _currentUserService; | ||
private readonly ApplicationContext _context; | ||
private readonly IMapper _mapper; | ||
|
||
public GetMentorsCommandHandler(ICurrentUserService currentUserService, ApplicationContext context, | ||
IMapper mapper) | ||
{ | ||
_currentUserService = currentUserService; | ||
_context = context; | ||
_mapper = mapper; | ||
} | ||
|
||
|
||
public async Task<IResult<List<GetMentorsResponse>>> Handle(GetMentorsCommand request, | ||
CancellationToken cancellationToken) | ||
{ | ||
if (string.IsNullOrEmpty(_currentUserService.AppUserId)) | ||
{ | ||
return await Result<List<GetMentorsResponse>>.FailAsync("Invalid user"); | ||
} | ||
|
||
var mentors = await _context.ProgramsMentors.Include(y => y.Programme).Include(x => x.AppUser).Where(x => x.AppUserId == _currentUserService.AppUserId).ToListAsync(); | ||
if (mentors == null) | ||
{ | ||
return await Result<List<GetMentorsResponse>>.FailAsync("No Mentors Available"); | ||
} | ||
|
||
var result = _mapper.Map<List<GetMentorsResponse>>(mentors); | ||
|
||
return await Result<List<GetMentorsResponse>>.SuccessAsync(result); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
backend/src/mms.Application/Mentors/Query/GetMentorsResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using mms.Domain.Entities; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using ProgrammEntity = mms.Domain.Entities.Programme; | ||
|
||
namespace mms.Application.Mentors.Query | ||
{ | ||
public class GetMentorsResponse | ||
{ | ||
public string ProgramId { get; set; } | ||
public string AppUserId { get; set; } | ||
public ProgrammEntity Programme { get; set; } | ||
public AppUser AppUser { get; set; } | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
backend/src/mms.Application/Programme/Command/CreateProgrammeCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using AspNetCoreHero.Results; | ||
using MediatR; | ||
using mms.Domain.Entities; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace mms.Application.Programme.Command | ||
{ | ||
public class CreateProgrammeCommand : IRequest<IResult> | ||
{ | ||
public string Name { get; set; } | ||
public string Description { get; set; } | ||
public string CreatedBy { get; set; } | ||
public string Status { get; set; } | ||
public string ArchivedBy { get; set; } | ||
public string ProgrammePicture { get; set; } | ||
public IList<UserTask> UserTasks { get; set; } | ||
public DateTime DateCreated { get; set; } | ||
public DateTime? DateCompleted { get; set; } | ||
public DateTime? DateArchived { get; set; } | ||
public string Criteria { get; set; } | ||
public IList<mms.Domain.Entities.Report> Reports { get; set; } | ||
public IList<ProgramsMentor> ProgramsMentors { get; set; } | ||
public IList<ProgrammeApplication> ProgrammeApplications { get; set; } | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
backend/src/mms.Application/Programme/Command/CreateProgrammeCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using AspNetCoreHero.Results; | ||
using AutoMapper; | ||
using MediatR; | ||
using mms.Application.Report.Command; | ||
using mms.Domain.Entities; | ||
using mms.Infrastructure.Context; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace mms.Application.Programme.Command | ||
{ | ||
public class CreateProgrammeCommandHandler : IRequestHandler<CreateProgrammeCommand, IResult> | ||
{ | ||
private readonly ApplicationContext _context; | ||
private readonly IMapper _mapper; | ||
|
||
public CreateProgrammeCommandHandler(ApplicationContext context, | ||
IMapper mapper) | ||
{ | ||
_context = context; | ||
_mapper = mapper; | ||
} | ||
|
||
public async Task<IResult> Handle(CreateProgrammeCommand request, CancellationToken cancellationToken) | ||
{ | ||
var programme = _mapper.Map<Domain.Entities.Programme>(request); | ||
|
||
programme.Id = Guid.NewGuid().ToString(); | ||
programme.CreatedAt = DateTime.Now; | ||
await _context.Programmes.AddAsync(programme); | ||
await _context.SaveChangesAsync(cancellationToken); | ||
return await Result.SuccessAsync(); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
backend/src/mms.Application/Programme/Query/GetActiveProgrammesCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using AspNetCoreHero.Results; | ||
using MediatR; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace mms.Application.Programme.Query | ||
{ | ||
public class GetActiveProgrammesCommand : IRequest<IResult<List<GetProgrammeResponse>>> | ||
{ | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
backend/src/mms.Application/Programme/Query/GetActiveProgrammesCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using AspNetCoreHero.Results; | ||
using AutoMapper; | ||
using MediatR; | ||
using Microsoft.EntityFrameworkCore; | ||
using mms.Infrastructure.Context; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace mms.Application.Programme.Query | ||
{ | ||
public class GetActiveProgrammesCommandHandler : IRequestHandler<GetActiveProgrammesCommand, | ||
IResult<List<GetProgrammeResponse>>> | ||
{ | ||
private readonly ApplicationContext _context; | ||
private readonly IMapper _mapper; | ||
|
||
public GetActiveProgrammesCommandHandler(ApplicationContext context, | ||
IMapper mapper) | ||
{ | ||
_context = context; | ||
_mapper = mapper; | ||
} | ||
|
||
public async Task<IResult<List<GetProgrammeResponse>>> Handle(GetActiveProgrammesCommand request, | ||
CancellationToken cancellationToken) | ||
{ | ||
var programmes = await _context.Programmes.Where(x => x.Status == "Active").OrderByDescending(x => x.DateCreated).ToListAsync(); | ||
if (programmes == null) | ||
{ | ||
return await Result<List<GetProgrammeResponse>>.FailAsync("No Active Programmes Available"); | ||
} | ||
|
||
var result = _mapper.Map<List<GetProgrammeResponse>>(programmes); | ||
|
||
return await Result<List<GetProgrammeResponse>>.SuccessAsync(result); | ||
} | ||
} | ||
} | ||
|
25 changes: 25 additions & 0 deletions
25
backend/src/mms.Application/Programme/Query/GetProgrammeResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using mms.Domain.Entities; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace mms.Application.Programme.Query | ||
{ | ||
public class GetProgrammeResponse | ||
{ | ||
|
||
public string Name { get; set; } | ||
public string Description { get; set; } | ||
public string CreatedBy { get; set; } | ||
public string Status { get; set; } | ||
public string ArchivedBy { get; set; } | ||
public string ProgrammePicture { get; set; } | ||
public DateTime? UpdatedAt { get; set; } | ||
public DateTime DateCreated { get; set; } | ||
public DateTime? DateCompleted { get; set; } | ||
public DateTime? DateArchived { get; set; } | ||
public string Criteria { get; set; } | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
backend/src/mms.Application/Programme/Query/GetProgrammesCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using AspNetCoreHero.Results; | ||
using MediatR; | ||
|
||
namespace mms.Application.Programme.Query | ||
{ | ||
public class GetProgrammesCommand : IRequest<IResult<List<GetProgrammeResponse>>> | ||
{ | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
backend/src/mms.Application/Programme/Query/GetProgrammesCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using AspNetCoreHero.Results; | ||
using AutoMapper; | ||
using MediatR; | ||
using Microsoft.EntityFrameworkCore; | ||
using mms.Application.UserPrivacy.Query; | ||
using mms.Application.UserTasks.Query; | ||
using mms.Infrastructure.Context; | ||
using mms.Infrastructure.Interface; | ||
|
||
namespace mms.Application.Programme.Query | ||
{ | ||
public class GetProgrammesCommandHandler : IRequestHandler<GetProgrammesCommand, | ||
IResult<List<GetProgrammeResponse>>> | ||
{ | ||
private readonly ApplicationContext _context; | ||
private readonly IMapper _mapper; | ||
|
||
public GetProgrammesCommandHandler( ApplicationContext context, | ||
IMapper mapper) | ||
{ | ||
_context = context; | ||
_mapper = mapper; | ||
} | ||
|
||
public async Task<IResult<List<GetProgrammeResponse>>> Handle(GetProgrammesCommand request, | ||
CancellationToken cancellationToken) | ||
{ | ||
var programmes = await _context.Programmes.OrderByDescending(x => x.DateCreated).ToListAsync(); | ||
if (programmes == null) | ||
{ | ||
return await Result<List<GetProgrammeResponse>>.FailAsync("No Programme Available"); | ||
} | ||
|
||
var result = _mapper.Map<List<GetProgrammeResponse>>(programmes); | ||
|
||
return await Result<List<GetProgrammeResponse>>.SuccessAsync(result); | ||
} | ||
} | ||
} |
Oops, something went wrong.