Changes in / [3b395c5:9885bee]
- Location:
- src
- Files:
-
- 3 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Clients/Angular/finki-chattery/src/app/shared-app/components/components.ts
r3b395c5 r9885bee 6 6 import { StudentCardComponent } from './question/student-card/student-card.component'; 7 7 8 export const COMPONENTS: any[] = [ 9 ButtonComponent, 10 FormErrorComponent, 11 FileUploadComponent, 12 QuestionPreviewComponent, 13 VoteComponent, 14 StudentCardComponent 15 ]; 8 export const COMPONENTS: any[] = [ButtonComponent, FormErrorComponent, FileUploadComponent, QuestionPreviewComponent, VoteComponent, StudentCardComponent]; -
src/Clients/Angular/finki-chattery/src/app/shared-app/directives/directives.ts
r3b395c5 r9885bee 1 import { 2 HandleInputFormErrorsDirective, 3 HoverElevationDirective, 4 LoaderDirective, 5 HandleSelectFormErrorsDirective, 6 ShareLinkDirective 7 } from '.'; 1 import { HandleInputFormErrorsDirective, HoverElevationDirective, LoaderDirective, HandleSelectFormErrorsDirective, ShareLinkDirective } from '.'; 8 2 9 export const DIRECTIVES: any[] = [ 10 HandleInputFormErrorsDirective, 11 LoaderDirective, 12 HoverElevationDirective, 13 HandleSelectFormErrorsDirective, 14 ShareLinkDirective 15 ]; 3 export const DIRECTIVES: any[] = [HandleInputFormErrorsDirective, LoaderDirective, HoverElevationDirective, HandleSelectFormErrorsDirective, ShareLinkDirective]; -
src/FinkiChattery/FinkiChattery.Api/Services/RegisterServices.cs
r3b395c5 r9885bee 9 9 using FinkiChattery.Persistence.Models; 10 10 using FinkiChattery.Persistence.Repositories; 11 using FinkiChattery.Persistence.UnitOfWork;12 11 using FinkiChattery.Queries.Questioning; 13 12 using Hangfire; … … 102 101 } 103 102 104 public static void Add UnitOfWork(this IServiceCollection services)103 public static void AddRepos(this IServiceCollection services) 105 104 { 106 services.AddScoped<IUnitOfWork, UnitOfWork>(); 105 services.AddScoped<ICategoriesRepo, CategoriesRepo>(); 106 services.AddScoped<ITeamRepo, TeamRepo>(); 107 services.AddScoped<IQuestionRepo, QuestionRepo>(); 108 services.AddScoped<IStudentRepo, StudentRepo>(); 107 109 } 108 110 -
src/FinkiChattery/FinkiChattery.Api/Startup.cs
r3b395c5 r9885bee 35 35 services.AddOriginUrlSettings(); 36 36 services.AddCurrentUser(); 37 services.Add UnitOfWork();37 services.AddRepos(); 38 38 services.AddAwsClient(Configuration); 39 39 services.AddHangfireService(Configuration); -
src/FinkiChattery/FinkiChattery.Commands/Questioning/AskQuestion/AskQuestionCommand.cs
r3b395c5 r9885bee 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 } -
src/FinkiChattery/FinkiChattery.Commands/Questioning/AskQuestion/AskQuestionValidator.cs
r3b395c5 r9885bee 1 1 using FinkiChattery.Commands.Questioning.Validators; 2 using FinkiChattery.Persistence. UnitOfWork;2 using FinkiChattery.Persistence.Repositories; 3 3 using FluentValidation; 4 4 … … 7 7 public class AskQuestionValidator : AbstractValidator<AskQuestionCommand> 8 8 { 9 public AskQuestionValidator(I UnitOfWork unitOfWork)9 public AskQuestionValidator(ICategoriesRepo categoriesRepo) 10 10 { 11 11 RuleFor(x => x.Title).QuestionTitleValidate(); 12 12 RuleFor(x => x.Text).QuestionTextValidate(); 13 RuleFor(x => x.Categories).Cascade(CascadeMode.Stop).ListNotNull().SetValidator(new CategoriesUidsExist( unitOfWork));13 RuleFor(x => x.Categories).Cascade(CascadeMode.Stop).ListNotNull().SetValidator(new CategoriesUidsExist(categoriesRepo)); 14 14 } 15 15 } -
src/FinkiChattery/FinkiChattery.Commands/Questioning/Validators/CategoriesUidsExist.cs
r3b395c5 r9885bee 1 1 using FinkiChattery.Persistence.Repositories; 2 using FinkiChattery.Persistence.UnitOfWork;3 2 using FluentValidation.Validators; 4 3 using System; … … 11 10 public class CategoriesUidsExist : AsyncValidatorBase 12 11 { 13 public CategoriesUidsExist(I UnitOfWork unitOfWork)12 public CategoriesUidsExist(ICategoriesRepo categoriesRepo) 14 13 { 15 UnitOfWork = unitOfWork;14 CategoriesRepo = categoriesRepo; 16 15 } 17 16 18 public I UnitOfWork UnitOfWork{ get; }17 public ICategoriesRepo CategoriesRepo { get; } 19 18 20 19 protected override async Task<bool> IsValidAsync(PropertyValidatorContext context, CancellationToken cancellation) … … 22 21 var categoriesUids = (IEnumerable<Guid>)context.PropertyValue; 23 22 24 return await UnitOfWork.Categories.CategoriesExist(categoriesUids);23 return await CategoriesRepo.CategoriesExist(categoriesUids); 25 24 } 26 25 -
src/FinkiChattery/FinkiChattery.Commands/Questioning/Validators/TeamWithUidExist.cs
r3b395c5 r9885bee 1 using FinkiChattery.Persistence. UnitOfWork;1 using FinkiChattery.Persistence.Repositories; 2 2 using FluentValidation.Validators; 3 3 using System; … … 9 9 public class TeamWithUidExist : AsyncValidatorBase 10 10 { 11 public TeamWithUidExist(I UnitOfWork unitOfWork)11 public TeamWithUidExist(ITeamRepo teamRepo) 12 12 { 13 UnitOfWork = unitOfWork;13 TeamRepo = teamRepo; 14 14 } 15 15 16 public I UnitOfWork UnitOfWork{ get; }16 public ITeamRepo TeamRepo { get; } 17 17 18 18 protected override async Task<bool> IsValidAsync(PropertyValidatorContext context, CancellationToken cancellation) 19 19 { 20 20 var teamUid = (Guid)context.PropertyValue; 21 return await UnitOfWork.Teams.TeamWithUidExists(teamUid);21 return await TeamRepo.TeamWithUidExists(teamUid); 22 22 } 23 23 -
src/FinkiChattery/FinkiChattery.Persistence/Repositories/Base/IRepository.cs
r3b395c5 r9885bee 13 13 Task<T> GetByIdAsync(int id); 14 14 15 voidAdd(T entity);15 Task Add(T entity); 16 16 } 17 17 } -
src/FinkiChattery/FinkiChattery.Persistence/Repositories/Base/Repository.cs
r3b395c5 r9885bee 29 29 } 30 30 31 public voidAdd(T entity)31 public async Task Add(T entity) 32 32 { 33 33 DbSet.Add(entity); 34 await DbContext.SaveChangesAsync(); 34 35 } 35 36 -
src/FinkiChattery/FinkiChattery.Persistence/Repositories/Contracts/ICategoriesRepo.cs
r3b395c5 r9885bee 8 8 namespace FinkiChattery.Persistence.Repositories 9 9 { 10 public interface ICategoriesRepo : IRepository<Category>10 public interface ICategoriesRepo 11 11 { 12 12 public Task<bool> CategoriesExist(IEnumerable<Guid> categoriesUids); -
src/FinkiChattery/FinkiChattery.Persistence/Repositories/Contracts/IQuestionRepo.cs
r3b395c5 r9885bee 1 using FinkiChattery.Persistence.Models; 2 using FinkiChattery.Persistence.Repositories.Contracts; 1 using FinkiChattery.Persistence.Repositories.Contracts; 3 2 using System; 4 3 using System.Threading.Tasks; … … 6 5 namespace FinkiChattery.Persistence.Repositories 7 6 { 8 public interface IQuestionRepo : IRepository<Question>7 public interface IQuestionRepo 9 8 { 10 9 Task<QuestionStateDto> GetQuestionState(Guid questionUid); -
src/FinkiChattery/FinkiChattery.Persistence/Repositories/Contracts/IStudentRepo.cs
r3b395c5 r9885bee 4 4 namespace FinkiChattery.Persistence.Repositories 5 5 { 6 public interface IStudentRepo : IRepository<Student>6 public interface IStudentRepo 7 7 { 8 8 public Task<Student> GetStudent(long applicationUserFk); -
src/FinkiChattery/FinkiChattery.Persistence/Repositories/Contracts/ITeamRepo.cs
r3b395c5 r9885bee 1 using FinkiChattery.Persistence.Models; 2 using System; 1 using System; 3 2 using System.Threading.Tasks; 4 3 5 4 namespace FinkiChattery.Persistence.Repositories 6 5 { 7 public interface ITeamRepo : IRepository<Team>6 public interface ITeamRepo 8 7 { 9 8 public Task<bool> TeamWithUidExists(Guid teamUid); -
src/FinkiChattery/FinkiChattery.Queries/Questioning/GetQuestionState/GetQuestionStateQuery.cs
r3b395c5 r9885bee 1 1 using FinkiChattery.Common.Mediator.Contracs; 2 using FinkiChattery.Persistence.Repositories; 2 3 using FinkiChattery.Persistence.Repositories.Contracts; 3 using FinkiChattery.Persistence.UnitOfWork;4 4 using System; 5 5 using System.Threading; … … 20 20 public class GetQuestionStateQueryHandler : IQueryHandler<GetQuestionStateQuery, QuestionStateDto> 21 21 { 22 public GetQuestionStateQueryHandler(I UnitOfWork unitOfWork)22 public GetQuestionStateQueryHandler(IQuestionRepo questionRepo) 23 23 { 24 UnitOfWork = unitOfWork;24 QuestionRepo = questionRepo; 25 25 } 26 26 27 public I UnitOfWork UnitOfWork{ get; }27 public IQuestionRepo QuestionRepo { get; } 28 28 29 29 public async Task<QuestionStateDto> Handle(GetQuestionStateQuery request, CancellationToken cancellationToken) 30 30 { 31 return await UnitOfWork.Questions.GetQuestionState(request.QuestionUid);31 return await QuestionRepo.GetQuestionState(request.QuestionUid); 32 32 } 33 33 }
Note:
See TracChangeset
for help on using the changeset viewer.