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