Changeset 7146ebb
- Timestamp:
- 09/08/21 17:49:03 (3 years ago)
- Branches:
- dev
- Children:
- cba21c9
- Parents:
- cabaa79
- Location:
- src/FinkiChattery
- Files:
-
- 24 added
- 19 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
src/FinkiChattery/FinkiChattery.Api/FinkiChattery.Api.csproj
rcabaa79 r7146ebb 13 13 <PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" /> 14 14 <PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" /> 15 <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.0.0" /> 15 16 <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.5"> 16 17 <PrivateAssets>all</PrivateAssets> … … 21 22 22 23 <ItemGroup> 24 <ProjectReference Include="..\FinkiChattery.Commands\FinkiChattery.Commands.csproj" /> 23 25 <ProjectReference Include="..\FinkiChattery.Common\FinkiChattery.Common.csproj" /> 26 <ProjectReference Include="..\FinkiChattery.Contracts\FinkiChattery.Contracts.csproj" /> 24 27 <ProjectReference Include="..\FinkiChattery.Persistence\FinkiChattery.Persistence.csproj" /> 25 </ItemGroup>26 27 <ItemGroup>28 <Folder Include="Controllers\" />29 28 </ItemGroup> 30 29 -
src/FinkiChattery/FinkiChattery.Api/Services/RegisterServices.cs
rcabaa79 r7146ebb 1 using FinkiChattery.Api.Services; 1 using FinkiChattery.Api.ApplicationServices.Authentication; 2 using FinkiChattery.Api.Services; 3 using FinkiChattery.Commands.Questioning; 2 4 using FinkiChattery.Common.Mediator; 3 5 using FinkiChattery.Common.Mediator.Interfaces; … … 6 8 using FinkiChattery.Persistence.Context; 7 9 using FinkiChattery.Persistence.Models; 10 using FinkiChattery.Persistence.Repositories; 8 11 using Hangfire; 9 12 using Hangfire.SqlServer; 10 13 using MediatR; 11 14 using Microsoft.AspNetCore.Authentication.JwtBearer; 15 using Microsoft.AspNetCore.Authorization; 12 16 using Microsoft.AspNetCore.Http; 13 17 using Microsoft.AspNetCore.Identity; … … 25 29 services.AddScoped<IEventService, EventService>(); 26 30 services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>)); 27 28 // TODO: REGISTER MEDIATOR HANDLERS WHEN WE CREATE FIRST COMMAND SMENI SO DOMAIN KLASA 29 services.AddMediatR(typeof(RegisterServices)); 31 services.AddMediatR(typeof(AskQuestionCommand)); 30 32 } 31 33 … … 74 76 }); 75 77 76 services.AddAuthorization(); 78 services.AddScoped<IAuthorizationHandler, CurrentUserIsOfRoleRequirementHandler>(); 79 80 services.AddAuthorization(options => 81 { 82 options.AddPolicy(AuthenticationPolicy.Student, policy => policy.Requirements.Add(new StudentRequirement())); 83 84 }); 77 85 } 78 86 … … 94 102 public static void AddRepos(this IServiceCollection services) 95 103 { 104 services.AddScoped<ICategoriesRepo, CategoriesRepo>(); 105 services.AddScoped<ITeamRepo, TeamRepo>(); 106 services.AddScoped<IQuestionRepo, QuestionRepo>(); 107 services.AddScoped<IStudentRepo, StudentRepo>(); 96 108 } 97 109 -
src/FinkiChattery/FinkiChattery.Api/Startup.cs
rcabaa79 r7146ebb 2 2 using FinkiChattery.Api.Server; 3 3 using FinkiChattery.Api.Services; 4 using FinkiChattery.Commands.Questioning; 4 5 using FinkiChattery.Persistence.Context; 6 using FluentValidation.AspNetCore; 5 7 using Hangfire; 6 8 using Microsoft.AspNetCore.Builder; … … 41 43 42 44 services.AddControllers() 43 .ConfigureApiBehaviorOptions(options => options.InvalidModelStateResponseFactory = context => new BadRequestObjectResult(context.ModelState)) ;44 // TODO: validators45 // .AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining<CreateOrganizerWithOrganizationValidator>());45 .ConfigureApiBehaviorOptions(options => options.InvalidModelStateResponseFactory = context => new BadRequestObjectResult(context.ModelState)) 46 .AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining<AskQuestionValidator>()); 47 services.AddApiVersioning(); 46 48 47 49 services.AddCors(options => -
src/FinkiChattery/FinkiChattery.Commands/FinkiChattery.Commands.csproj
rcabaa79 r7146ebb 5 5 </PropertyGroup> 6 6 7 <ItemGroup> 8 <ProjectReference Include="..\FinkiChattery.Common\FinkiChattery.Common.csproj" /> 9 <ProjectReference Include="..\FinkiChattery.Persistence\FinkiChattery.Persistence.csproj" /> 10 </ItemGroup> 11 7 12 </Project> -
src/FinkiChattery/FinkiChattery.Common/Errors/ErrorCodes.cs
rcabaa79 r7146ebb 1 1 namespace FinkiChattery.Common.Errors 2 2 { 3 public staticclass ErrorCodes3 public class ErrorCodes 4 4 { 5 public const string CantBeNull = "CantBeNull"; 5 6 } 6 7 } -
src/FinkiChattery/FinkiChattery.Database/FinkiChattery.Database.sqlproj
rcabaa79 r7146ebb 66 66 <Folder Include="dbo\Tables\User" /> 67 67 <Folder Include="dbo\Tables\User\Seed" /> 68 <Folder Include="dbo\Tables\Category" /> 69 <Folder Include="dbo\Tables\Team" /> 70 <Folder Include="dbo\Tables\Student" /> 68 71 </ItemGroup> 69 72 <ItemGroup> 70 <Build Include="dbo\Tables\Category.sql" />71 <Build Include="dbo\Tables\Team.sql" />72 73 <Build Include="dbo\Tables\Moderator.sql" /> 73 <Build Include="dbo\Tables\Student.sql" />74 74 <Build Include="dbo\Tables\Teacher.sql" /> 75 75 <Build Include="dbo\Tables\Question.sql" /> … … 83 83 <Build Include="dbo\Tables\User\AspNetRoles.sql" /> 84 84 <None Include="dbo\Tables\User\Seed\Users.Debug.Seed.sql" /> 85 <Build Include="dbo\Tables\Category\Category.sql" /> 86 <None Include="dbo\Tables\Category\Category.Seed.sql" /> 87 <Build Include="dbo\Tables\Team\Team.sql" /> 88 <Build Include="dbo\Tables\Student\Student.sql" /> 89 <None Include="dbo\Tables\Student\Student.Debug.Seed.sql" /> 85 90 </ItemGroup> 86 91 <ItemGroup> -
src/FinkiChattery/FinkiChattery.Database/dbo/Scripts/PostDeploymentScripts/Debug.PostDeployment.sql
rcabaa79 r7146ebb 1 1 :r .\..\..\Tables\User\Seed\Users.Debug.Seed.sql 2 :r .\..\..\Tables\Category\Category.Seed.sql 3 :r .\..\..\Tables\Student\Student.Debug.Seed.sql -
src/FinkiChattery/FinkiChattery.Database/dbo/Scripts/PostDeploymentScripts/Production.PostDeployment.sql
rcabaa79 r7146ebb 1 1 :r .\..\..\Tables\Category\Category.Seed.sql -
src/FinkiChattery/FinkiChattery.Database/dbo/Tables/Answer.sql
rcabaa79 r7146ebb 2 2 [Id] BIGINT IDENTITY (1, 1) NOT NULL, 3 3 [Uid] UNIQUEIDENTIFIER NOT NULL, 4 [Text] NVARCHAR ( 1)NOT NULL,4 [Text] NVARCHAR (4000) NOT NULL, 5 5 [QuestionFk] BIGINT NOT NULL, 6 6 [StudentFk] BIGINT NOT NULL, -
src/FinkiChattery/FinkiChattery.Database/dbo/Tables/AnswerResponse.sql
rcabaa79 r7146ebb 2 2 [Id] BIGINT IDENTITY (1, 1) NOT NULL, 3 3 [Uid] UNIQUEIDENTIFIER NOT NULL, 4 [Text] NVARCHAR ( 1)NOT NULL,4 [Text] NVARCHAR (4000) NOT NULL, 5 5 [AnswerFk] BIGINT NOT NULL, 6 6 [StudentFk] BIGINT NOT NULL, -
src/FinkiChattery/FinkiChattery.Database/dbo/Tables/Category/Category.sql
rcabaa79 r7146ebb 2 2 [Id] BIGINT IDENTITY (1, 1) NOT NULL, 3 3 [Uid] UNIQUEIDENTIFIER NOT NULL, 4 [Name] NVARCHAR ( 1) NOT NULL,4 [Name] NVARCHAR (500) NOT NULL, 5 5 CONSTRAINT [PK_Category] PRIMARY KEY CLUSTERED ([Id] ASC) 6 6 ); -
src/FinkiChattery/FinkiChattery.Database/dbo/Tables/Question.sql
rcabaa79 r7146ebb 2 2 [Id] BIGINT IDENTITY (1, 1) NOT NULL, 3 3 [Uid] UNIQUEIDENTIFIER NOT NULL, 4 [Title] NVARCHAR ( 1) NOT NULL,4 [Title] NVARCHAR (500) NOT NULL, 5 5 [Text] NVARCHAR (MAX) NULL, 6 6 [StudentFk] BIGINT NOT NULL, -
src/FinkiChattery/FinkiChattery.Database/dbo/Tables/Student/Student.sql
rcabaa79 r7146ebb 3 3 [Uid] UNIQUEIDENTIFIER NOT NULL, 4 4 [ApplicationUserFk] BIGINT NOT NULL, 5 [IndexNumber] NVARCHAR ( 1) NOT NULL,5 [IndexNumber] NVARCHAR (50) NOT NULL, 6 6 [Reputation] BIGINT DEFAULT (CONVERT([bigint],(0))) NOT NULL, 7 7 [ReportReputation] BIGINT DEFAULT (CONVERT([bigint],(0))) NOT NULL, 8 [ImageUrl] NVARCHAR (1 ) NOT NULL,8 [ImageUrl] NVARCHAR (1000) NOT NULL, 9 9 CONSTRAINT [PK_Student] PRIMARY KEY CLUSTERED ([Id] ASC), 10 10 CONSTRAINT [FK_Student_AspNetUsers_ApplicationUserFk] FOREIGN KEY ([ApplicationUserFk]) REFERENCES [dbo].[AspNetUsers] ([Id]) -
src/FinkiChattery/FinkiChattery.Persistence/Configurations/QuestionConfig.cs
rcabaa79 r7146ebb 1 using Microsoft.EntityFrameworkCore; 1 using FinkiChattery.Persistence.Models; 2 using Microsoft.EntityFrameworkCore; 2 3 using Microsoft.EntityFrameworkCore.Metadata.Builders; 3 using System;4 using System.Collections.Generic;5 using System.Linq;6 using System.Text;7 using System.Threading.Tasks;8 using FinkiChattery.Persistence.Models;9 4 10 5 namespace FinkiChattery.Persistence.Configurations … … 23 18 24 19 builder.Property(x => x.Title).HasColumnName(@"Title").HasColumnType("nvarchar").IsRequired().HasMaxLength(500); 25 builder.Property(x => x.Te amFk).HasColumnName(@"Team").HasColumnType("nvarchar").IsRequired().HasMaxLength(4000);20 builder.Property(x => x.Text).HasColumnName(@"Text").HasColumnType("nvarchar").IsRequired().HasMaxLength(4000); 26 21 builder.Property(x => x.StudentFk).HasColumnName(@"StudentFk").HasColumnType("bigint").IsRequired(); 27 22 builder.Property(x => x.CreatedOn).HasColumnName(@"CreatedOn").HasColumnType("smalldatetime").IsRequired(); -
src/FinkiChattery/FinkiChattery.Persistence/Models/Answer.cs
rcabaa79 r7146ebb 20 20 public DateTime CreatedOn { get; set; } 21 21 22 public virtual I Enumerable<Upvote> Upvotes { get; set; }22 public virtual ICollection<Upvote> Upvotes { get; set; } 23 23 24 public virtual I Enumerable<AnswerResponse> AnswerResponses { get; set; }24 public virtual ICollection<AnswerResponse> AnswerResponses { get; set; } 25 25 26 26 } -
src/FinkiChattery/FinkiChattery.Persistence/Models/Base/BaseEntity.cs
rcabaa79 r7146ebb 1 1 using System; 2 using System.Collections.Generic;3 using System.Linq;4 using System.Text;5 using System.Threading.Tasks;6 2 7 3 namespace FinkiChattery.Persistence.Models … … 9 5 public class BaseEntity 10 6 { 7 public BaseEntity() 8 { 9 Uid = Guid.NewGuid(); 10 } 11 11 12 public long Id { get; set; } 12 13 -
src/FinkiChattery/FinkiChattery.Persistence/Models/Question.cs
rcabaa79 r7146ebb 6 6 public class Question : BaseEntity 7 7 { 8 public Question() : base() 9 { 10 CreatedOn = DateTime.UtcNow; 11 LastActiveOn = DateTime.UtcNow; 12 Answers = new List<Answer>(); 13 QuestionCategories = new List<QuestionCategory>(); 14 } 15 8 16 public string Title { get; set; } 9 17 … … 24 32 public DateTime LastActiveOn { get; set; } 25 33 26 public virtual I Enumerable<Answer> Answers { get; set; }34 public virtual ICollection<Answer> Answers { get; set; } 27 35 28 public virtual I Enumerable<QuestionCategory> QuestionCategories { get; set; }36 public virtual ICollection<QuestionCategory> QuestionCategories { get; set; } 29 37 30 38 // TODO: Pole po koe ke pravime queries -
src/FinkiChattery/FinkiChattery.Persistence/Models/QuestionCategory.cs
rcabaa79 r7146ebb 9 9 public class QuestionCategory : BaseEntity 10 10 { 11 public QuestionCategory() : base() 12 { 13 } 14 11 15 public long QuestionFk { get; set; } 12 16 -
src/FinkiChattery/FinkiChattery.Persistence/Models/Student.cs
rcabaa79 r7146ebb 21 21 public string ImageUrl { get; set; } 22 22 23 public virtual I Enumerable<Question> Questions { get; set; }23 public virtual ICollection<Question> Questions { get; set; } 24 24 25 public virtual I Enumerable<Answer> Answers { get; set; }25 public virtual ICollection<Answer> Answers { get; set; } 26 26 27 public virtual I Enumerable<StudentTeam> StudentTeams { get; set; }27 public virtual ICollection<StudentTeam> StudentTeams { get; set; } 28 28 } 29 29 } -
src/FinkiChattery/FinkiChattery.Persistence/Models/Teacher.cs
rcabaa79 r7146ebb 13 13 public virtual ApplicationUser ApplicationUser { get; set; } 14 14 15 public virtual I Enumerable<TeacherTeam> TeacherTeams { get; set; }15 public virtual ICollection<TeacherTeam> TeacherTeams { get; set; } 16 16 17 17 } -
src/FinkiChattery/FinkiChattery.Persistence/Models/Team.cs
rcabaa79 r7146ebb 13 13 public string Description { get; set; } 14 14 15 public virtual I Enumerable<Question> Questions{ get; set; }15 public virtual ICollection<Question> Questions{ get; set; } 16 16 17 public virtual I Enumerable<StudentTeam> TeamStudents { get; set; }17 public virtual ICollection<StudentTeam> TeamStudents { get; set; } 18 18 19 public virtual I Enumerable<TeacherTeam> TeamTeachers { get; set; }19 public virtual ICollection<TeacherTeam> TeamTeachers { get; set; } 20 20 } 21 21 }
Note:
See TracChangeset
for help on using the changeset viewer.