Changeset ad079e5 for src


Ignore:
Timestamp:
10/31/21 12:13:35 (3 years ago)
Author:
Стојков Марко <mst@…>
Branches:
dev
Children:
7c3e6a8
Parents:
ad0fcd3
Message:

Vote answer endpoint

Location:
src/FinkiChattery
Files:
15 added
7 edited

Legend:

Unmodified
Added
Removed
  • src/FinkiChattery/FinkiChattery.Api/Services/RegisterServices.cs

    rad0fcd3 rad079e5  
    11using FinkiChattery.Api.ApplicationServices.Authentication;
     2using FinkiChattery.Api.ApplicationServices.Questioning.EventHandlers;
    23using FinkiChattery.Api.Services;
    34using FinkiChattery.Commands.Questioning;
     
    3132            services.AddScoped<IEventService, EventService>();
    3233            services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
    33             services.AddMediatR(typeof(AskQuestionCommand), typeof(GetQuestionStateQuery));
     34            services.AddMediatR(typeof(AskQuestionCommand), typeof(GetQuestionStateQuery), typeof(UpdateAnswerVotesEventHandler));
    3435        }
    3536
     
    5455            });
    5556            services.AddHangfireServer();
     57
     58            services.AddScoped<IBackgroundJobClient>(provider =>
     59            {
     60                return new BackgroundJobClient(JobStorage.Current);
     61            });
    5662        }
    5763
  • src/FinkiChattery/FinkiChattery.Commands/Questioning/QuestioningErrorCodes.cs

    rad0fcd3 rad079e5  
    99        public const string CategoriesDontExist = "CategoriesDontExist";
    1010        public const string TeamDontExist = "TeamDontExist";
     11        public const string AnswerAlreadyUpvoted = "AnswerAlreadyUpvoted";
     12        public const string AnswerAlreadyDownvoted = "AnswerAlreadyDownvoted";
     13        public const string StudentHasBadReputation = "StudentHasBadReputation";
    1114    }
    1215}
  • src/FinkiChattery/FinkiChattery.Commands/Questioning/Validators/CategoriesUidsExist.cs

    rad0fcd3 rad079e5  
    1 using FinkiChattery.Persistence.Repositories;
    2 using FinkiChattery.Persistence.UnitOfWork;
     1using FinkiChattery.Persistence.UnitOfWork;
    32using FluentValidation.Validators;
    43using System;
  • src/FinkiChattery/FinkiChattery.Persistence/Models/Student.cs

    rad0fcd3 rad079e5  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using System.Threading.Tasks;
     1using System.Collections.Generic;
    62
    73namespace FinkiChattery.Persistence.Models
     
    2218
    2319        public virtual ICollection<Question> Questions { get; set; }
    24        
     20
    2521        public virtual ICollection<Answer> Answers { get; set; }
    26        
     22
    2723        public virtual ICollection<StudentTeam> StudentTeams { get; set; }
    2824    }
  • src/FinkiChattery/FinkiChattery.Persistence/Models/Vote.cs

    rad0fcd3 rad079e5  
    55    public class Vote : BaseEntity
    66    {
     7        public Vote() : base()
     8        {
     9        }
     10
    711        public long StudentFk { get; set; }
    812
  • src/FinkiChattery/FinkiChattery.Persistence/UnitOfWork/Contracts/IUnitOfWork.cs

    rad0fcd3 rad079e5  
    1111        IStudentRepo Students { get; }
    1212        ITeamRepo Teams { get; }
     13        IVoteRepo Votes { get; }
     14        IAnswerRepo Answers { get; }
    1315        Task<int> SaveAsync();
    1416    }
  • src/FinkiChattery/FinkiChattery.Persistence/UnitOfWork/Implementations/UnitOfWork.cs

    rad0fcd3 rad079e5  
    1212        private StudentRepo _students;
    1313        private TeamRepo _teams;
     14        private VoteRepo _votes;
     15        private AnswerRepo _answers;
    1416
    1517        public UnitOfWork(ApplicationDbContext dbContext)
     
    7072        }
    7173
     74        public IVoteRepo Votes
     75        {
     76            get
     77            {
     78                if (_votes == null)
     79                {
     80                    _votes = new VoteRepo(DbContext);
     81                }
     82
     83                return _votes;
     84            }
     85        }
     86
     87        public IAnswerRepo Answers
     88        {
     89            get
     90            {
     91                if (_answers == null)
     92                {
     93                    _answers = new AnswerRepo(DbContext);
     94                }
     95
     96                return _answers;
     97            }
     98        }
     99
    72100        public ApplicationDbContext DbContext { get; }
    73101
Note: See TracChangeset for help on using the changeset viewer.