-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ccc993
commit db4fe07
Showing
25 changed files
with
670 additions
and
73 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
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
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
17 changes: 17 additions & 0 deletions
17
UrphaCapital.Application/UseCases/Homework/Commands/GradeHomeworkCommand.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,17 @@ | ||
using MediatR; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UrphaCapital.Application.ViewModels; | ||
|
||
namespace UrphaCapital.Application.UseCases.Homework.Commands | ||
{ | ||
public class GradeHomeworkCommand : IRequest<ResponseModel> | ||
{ | ||
public long HomeworkId { get; set; } | ||
public long MentorId { get; set; } | ||
public int Grade { get; set; } | ||
} | ||
} |
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
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
33 changes: 33 additions & 0 deletions
33
UrphaCapital.Application/UseCases/Homework/Handlers/GradeHomeworkCommandHandler.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,33 @@ | ||
using MediatR; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UrphaCapital.Application.Abstractions; | ||
using UrphaCapital.Application.UseCases.Homework.Commands; | ||
using UrphaCapital.Application.ViewModels; | ||
|
||
namespace UrphaCapital.Application.UseCases.Homework.Handlers | ||
{ | ||
public class GradeHomeworkCommandHandler : IRequestHandler<GradeHomeworkCommand, ResponseModel> | ||
{ | ||
private readonly IApplicationDbContext _context; | ||
public async Task<ResponseModel> Handle(GradeHomeworkCommand request, CancellationToken cancellationToken) | ||
{ | ||
var homework = await _context.Homeworks.FindAsync(request.HomeworkId); | ||
if (homework == null) return new ResponseModel() { IsSuccess = false, Message = "Not Found", StatusCode = 404 }; | ||
|
||
homework.Grade = request.Grade; | ||
homework.MentorId = request.MentorId; | ||
await _context.SaveChangesAsync(); | ||
|
||
return new ResponseModel() | ||
{ | ||
IsSuccess = true, | ||
Message = "Successfully Graded", | ||
StatusCode = 200 | ||
}; | ||
} | ||
} | ||
} |
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
15 changes: 0 additions & 15 deletions
15
UrphaCapital.Application/UseCases/Homework/Queries/GetHomeworkByStudentIdQuery.cs
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
UrphaCapital.Application/UseCases/Homework/Queries/GetStudentHomeworkResultsQuery.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,17 @@ | ||
using MediatR; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UrphaCapital.Domain.DTOs; | ||
|
||
namespace UrphaCapital.Application.UseCases.Homework.Queries | ||
{ | ||
public class GetStudentHomeworkResultsQuery : IRequest<IEnumerable<HomeworkResultView>> | ||
{ | ||
public long StudentId { get; set; } | ||
public int Index { get; set; } | ||
public int Count { get; set; } | ||
} | ||
} |
28 changes: 0 additions & 28 deletions
28
...pital.Application/UseCases/Homework/QueriesHandler/GetHomeworksByStudentIdQueryHandler.cs
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
...tal.Application/UseCases/Homework/QueriesHandler/GetStudentHomeworkResultsQueryHandler.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 MediatR; | ||
using Microsoft.EntityFrameworkCore; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using UrphaCapital.Application.Abstractions; | ||
using UrphaCapital.Application.UseCases.Homework.Queries; | ||
using UrphaCapital.Domain.DTOs; | ||
using UrphaCapital.Domain.Entities.Auth; | ||
|
||
namespace UrphaCapital.Application.UseCases.Homework.QueriesHandler | ||
{ | ||
public class GetStudentHomeworkResultsQueryHandler : IRequestHandler<GetStudentHomeworkResultsQuery, IEnumerable<HomeworkResultView>> | ||
{ | ||
private readonly IApplicationDbContext _context; | ||
|
||
public GetStudentHomeworkResultsQueryHandler(IApplicationDbContext context) | ||
{ | ||
_context = context; | ||
} | ||
|
||
public async Task<IEnumerable<HomeworkResultView>> Handle(GetStudentHomeworkResultsQuery request, CancellationToken cancellationToken) | ||
{ | ||
var homeworkList = await _context.Homeworks | ||
.Where(h => h.StudentId == request.StudentId) | ||
.Skip(request.Index - 1) | ||
.Take(request.Count) | ||
.Include(h => h.Lesson) | ||
.ToListAsync(); | ||
|
||
var result = homeworkList.Select(h => new HomeworkResultView() | ||
{ | ||
HomeworkId = h.Id, | ||
FILE = h.FILE, | ||
Grade = h.Grade, | ||
LessonTitle = h.Lesson.Title | ||
}); | ||
|
||
return result; | ||
|
||
} | ||
} | ||
} |
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
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
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
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
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
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,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace UrphaCapital.Domain.DTOs | ||
{ | ||
public class HomeworkResultView | ||
{ | ||
public long HomeworkId { get; set; } | ||
public string LessonTitle { get; set; } | ||
public string FILE { get; set; } | ||
public int? Grade { get; set; } | ||
} | ||
} |
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
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
Oops, something went wrong.