Changes in src/FinkiChattery/FinkiChattery.Commands/Questioning/AskQuestion/AskQuestionCommand.cs [95d80e4:7146ebb]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/FinkiChattery/FinkiChattery.Commands/Questioning/AskQuestion/AskQuestionCommand.cs
r95d80e4 r7146ebb 1 1 using FinkiChattery.Common.Mediator.Contracs; 2 2 using FinkiChattery.Common.User; 3 using FinkiChattery.Persistence.Context; 3 4 using FinkiChattery.Persistence.Models; 4 using FinkiChattery.Persistence. UnitOfWork;5 using FinkiChattery.Persistence.Repositories; 5 6 using System; 6 7 using System.Collections.Generic; … … 26 27 public class AskQuestionHandler : ICommandHandler<AskQuestionCommand, Guid> 27 28 { 28 public AskQuestionHandler( IUnitOfWork unitOfWork, ICurrentUser currentUser)29 public AskQuestionHandler(ApplicationDbContext dbContext, ICategoriesRepo categoriesRepo, IStudentRepo studentRepo, ICurrentUser currentUser) 29 30 { 30 UnitOfWork = unitOfWork; 31 DbContext = dbContext; 32 CategoriesRepo = categoriesRepo; 33 StudentRepo = studentRepo; 31 34 CurrentUser = currentUser; 32 35 } 33 36 34 public IUnitOfWork UnitOfWork { get; } 37 public ApplicationDbContext DbContext { get; } 38 public ICategoriesRepo CategoriesRepo { get; } 39 public IStudentRepo StudentRepo { get; } 35 40 public ICurrentUser CurrentUser { get; } 36 41 37 42 public async Task<Guid> Handle(AskQuestionCommand request, CancellationToken cancellationToken) 38 43 { 39 var questionCategories = await UnitOfWork.Categories.GetCategories(request.Categories);40 var currentStudent = await UnitOfWork.Students.GetStudent(CurrentUser.Id);44 var questionCategories = await CategoriesRepo.GetCategories(request.Categories); 45 var currentStudent = await StudentRepo.GetStudent(CurrentUser.Id); 41 46 42 47 var questionDatabaseEntity = new Question() … … 55 60 } 56 61 57 UnitOfWork.Questions.Add(questionDatabaseEntity);58 await UnitOfWork.SaveAsync();62 DbContext.Questions.Add(questionDatabaseEntity); 63 await DbContext.SaveChangesAsync(); 59 64 return questionDatabaseEntity.Uid; 60 65 }
Note:
See TracChangeset
for help on using the changeset viewer.