Changes in / [3b395c5:9885bee]


Ignore:
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  
    66import { StudentCardComponent } from './question/student-card/student-card.component';
    77
    8 export const COMPONENTS: any[] = [
    9   ButtonComponent,
    10   FormErrorComponent,
    11   FileUploadComponent,
    12   QuestionPreviewComponent,
    13   VoteComponent,
    14   StudentCardComponent
    15 ];
     8export 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 '.';
     1import { HandleInputFormErrorsDirective, HoverElevationDirective, LoaderDirective, HandleSelectFormErrorsDirective, ShareLinkDirective } from '.';
    82
    9 export const DIRECTIVES: any[] = [
    10   HandleInputFormErrorsDirective,
    11   LoaderDirective,
    12   HoverElevationDirective,
    13   HandleSelectFormErrorsDirective,
    14   ShareLinkDirective
    15 ];
     3export const DIRECTIVES: any[] = [HandleInputFormErrorsDirective, LoaderDirective, HoverElevationDirective, HandleSelectFormErrorsDirective, ShareLinkDirective];
  • src/FinkiChattery/FinkiChattery.Api/Services/RegisterServices.cs

    r3b395c5 r9885bee  
    99using FinkiChattery.Persistence.Models;
    1010using FinkiChattery.Persistence.Repositories;
    11 using FinkiChattery.Persistence.UnitOfWork;
    1211using FinkiChattery.Queries.Questioning;
    1312using Hangfire;
     
    102101        }
    103102
    104         public static void AddUnitOfWork(this IServiceCollection services)
     103        public static void AddRepos(this IServiceCollection services)
    105104        {
    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>();
    107109        }
    108110
  • src/FinkiChattery/FinkiChattery.Api/Startup.cs

    r3b395c5 r9885bee  
    3535            services.AddOriginUrlSettings();
    3636            services.AddCurrentUser();
    37             services.AddUnitOfWork();
     37            services.AddRepos();
    3838            services.AddAwsClient(Configuration);
    3939            services.AddHangfireService(Configuration);
  • src/FinkiChattery/FinkiChattery.Commands/Questioning/AskQuestion/AskQuestionCommand.cs

    r3b395c5 r9885bee  
    11using FinkiChattery.Common.Mediator.Contracs;
    22using FinkiChattery.Common.User;
     3using FinkiChattery.Persistence.Context;
    34using FinkiChattery.Persistence.Models;
    4 using FinkiChattery.Persistence.UnitOfWork;
     5using FinkiChattery.Persistence.Repositories;
    56using System;
    67using System.Collections.Generic;
     
    2627    public class AskQuestionHandler : ICommandHandler<AskQuestionCommand, Guid>
    2728    {
    28         public AskQuestionHandler(IUnitOfWork unitOfWork, ICurrentUser currentUser)
     29        public AskQuestionHandler(ApplicationDbContext dbContext, ICategoriesRepo categoriesRepo, IStudentRepo studentRepo, ICurrentUser currentUser)
    2930        {
    30             UnitOfWork = unitOfWork;
     31            DbContext = dbContext;
     32            CategoriesRepo = categoriesRepo;
     33            StudentRepo = studentRepo;
    3134            CurrentUser = currentUser;
    3235        }
    3336
    34         public IUnitOfWork UnitOfWork { get; }
     37        public ApplicationDbContext DbContext { get; }
     38        public ICategoriesRepo CategoriesRepo { get; }
     39        public IStudentRepo StudentRepo { get; }
    3540        public ICurrentUser CurrentUser { get; }
    3641
    3742        public async Task<Guid> Handle(AskQuestionCommand request, CancellationToken cancellationToken)
    3843        {
    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);
    4146
    4247            var questionDatabaseEntity = new Question()
     
    5560            }
    5661
    57             UnitOfWork.Questions.Add(questionDatabaseEntity);
    58             await UnitOfWork.SaveAsync();
     62            DbContext.Questions.Add(questionDatabaseEntity);
     63            await DbContext.SaveChangesAsync();
    5964            return questionDatabaseEntity.Uid;
    6065        }
  • src/FinkiChattery/FinkiChattery.Commands/Questioning/AskQuestion/AskQuestionValidator.cs

    r3b395c5 r9885bee  
    11using FinkiChattery.Commands.Questioning.Validators;
    2 using FinkiChattery.Persistence.UnitOfWork;
     2using FinkiChattery.Persistence.Repositories;
    33using FluentValidation;
    44
     
    77    public class AskQuestionValidator : AbstractValidator<AskQuestionCommand>
    88    {
    9         public AskQuestionValidator(IUnitOfWork unitOfWork)
     9        public AskQuestionValidator(ICategoriesRepo categoriesRepo)
    1010        {
    1111            RuleFor(x => x.Title).QuestionTitleValidate();
    1212            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));
    1414        }
    1515    }
  • src/FinkiChattery/FinkiChattery.Commands/Questioning/Validators/CategoriesUidsExist.cs

    r3b395c5 r9885bee  
    11using FinkiChattery.Persistence.Repositories;
    2 using FinkiChattery.Persistence.UnitOfWork;
    32using FluentValidation.Validators;
    43using System;
     
    1110    public class CategoriesUidsExist : AsyncValidatorBase
    1211    {
    13         public CategoriesUidsExist(IUnitOfWork unitOfWork)
     12        public CategoriesUidsExist(ICategoriesRepo categoriesRepo)
    1413        {
    15             UnitOfWork = unitOfWork;
     14            CategoriesRepo = categoriesRepo;
    1615        }
    1716
    18         public IUnitOfWork UnitOfWork { get; }
     17        public ICategoriesRepo CategoriesRepo { get; }
    1918
    2019        protected override async Task<bool> IsValidAsync(PropertyValidatorContext context, CancellationToken cancellation)
     
    2221            var categoriesUids = (IEnumerable<Guid>)context.PropertyValue;
    2322
    24             return await UnitOfWork.Categories.CategoriesExist(categoriesUids);
     23            return await CategoriesRepo.CategoriesExist(categoriesUids);
    2524        }
    2625
  • src/FinkiChattery/FinkiChattery.Commands/Questioning/Validators/TeamWithUidExist.cs

    r3b395c5 r9885bee  
    1 using FinkiChattery.Persistence.UnitOfWork;
     1using FinkiChattery.Persistence.Repositories;
    22using FluentValidation.Validators;
    33using System;
     
    99    public class TeamWithUidExist : AsyncValidatorBase
    1010    {
    11         public TeamWithUidExist(IUnitOfWork unitOfWork)
     11        public TeamWithUidExist(ITeamRepo teamRepo)
    1212        {
    13             UnitOfWork = unitOfWork;
     13            TeamRepo = teamRepo;
    1414        }
    1515
    16         public IUnitOfWork UnitOfWork { get; }
     16        public ITeamRepo TeamRepo { get; }
    1717
    1818        protected override async Task<bool> IsValidAsync(PropertyValidatorContext context, CancellationToken cancellation)
    1919        {
    2020            var teamUid = (Guid)context.PropertyValue;
    21             return await UnitOfWork.Teams.TeamWithUidExists(teamUid);
     21            return await TeamRepo.TeamWithUidExists(teamUid);       
    2222        }
    2323
  • src/FinkiChattery/FinkiChattery.Persistence/Repositories/Base/IRepository.cs

    r3b395c5 r9885bee  
    1313        Task<T> GetByIdAsync(int id);
    1414
    15         void Add(T entity);
     15        Task Add(T entity);
    1616    }
    1717}
  • src/FinkiChattery/FinkiChattery.Persistence/Repositories/Base/Repository.cs

    r3b395c5 r9885bee  
    2929        }
    3030
    31         public void Add(T entity)
     31        public async Task Add(T entity)
    3232        {
    3333            DbSet.Add(entity);
     34            await DbContext.SaveChangesAsync();
    3435        }
    3536
  • src/FinkiChattery/FinkiChattery.Persistence/Repositories/Contracts/ICategoriesRepo.cs

    r3b395c5 r9885bee  
    88namespace FinkiChattery.Persistence.Repositories
    99{
    10     public interface ICategoriesRepo : IRepository<Category>
     10    public interface ICategoriesRepo
    1111    {
    1212        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;
     1using FinkiChattery.Persistence.Repositories.Contracts;
    32using System;
    43using System.Threading.Tasks;
     
    65namespace FinkiChattery.Persistence.Repositories
    76{
    8     public interface IQuestionRepo : IRepository<Question>
     7    public interface IQuestionRepo
    98    {
    109        Task<QuestionStateDto> GetQuestionState(Guid questionUid);
  • src/FinkiChattery/FinkiChattery.Persistence/Repositories/Contracts/IStudentRepo.cs

    r3b395c5 r9885bee  
    44namespace FinkiChattery.Persistence.Repositories
    55{
    6     public interface IStudentRepo : IRepository<Student>
     6    public interface IStudentRepo
    77    {
    88        public Task<Student> GetStudent(long applicationUserFk);
  • src/FinkiChattery/FinkiChattery.Persistence/Repositories/Contracts/ITeamRepo.cs

    r3b395c5 r9885bee  
    1 using FinkiChattery.Persistence.Models;
    2 using System;
     1using System;
    32using System.Threading.Tasks;
    43
    54namespace FinkiChattery.Persistence.Repositories
    65{
    7     public interface ITeamRepo : IRepository<Team>
     6    public interface ITeamRepo
    87    {
    98        public Task<bool> TeamWithUidExists(Guid teamUid);
  • src/FinkiChattery/FinkiChattery.Queries/Questioning/GetQuestionState/GetQuestionStateQuery.cs

    r3b395c5 r9885bee  
    11using FinkiChattery.Common.Mediator.Contracs;
     2using FinkiChattery.Persistence.Repositories;
    23using FinkiChattery.Persistence.Repositories.Contracts;
    3 using FinkiChattery.Persistence.UnitOfWork;
    44using System;
    55using System.Threading;
     
    2020    public class GetQuestionStateQueryHandler : IQueryHandler<GetQuestionStateQuery, QuestionStateDto>
    2121    {
    22         public GetQuestionStateQueryHandler(IUnitOfWork unitOfWork)
     22        public GetQuestionStateQueryHandler(IQuestionRepo questionRepo)
    2323        {
    24             UnitOfWork = unitOfWork;
     24            QuestionRepo = questionRepo;
    2525        }
    2626
    27         public IUnitOfWork UnitOfWork { get; }
     27        public IQuestionRepo QuestionRepo { get; }
    2828
    2929        public async Task<QuestionStateDto> Handle(GetQuestionStateQuery request, CancellationToken cancellationToken)
    3030        {
    31             return await UnitOfWork.Questions.GetQuestionState(request.QuestionUid);
     31            return await QuestionRepo.GetQuestionState(request.QuestionUid);
    3232        }
    3333    }
Note: See TracChangeset for help on using the changeset viewer.