Changeset dd731cd
- Timestamp:
- 10/21/21 20:19:15 (3 years ago)
- Branches:
- dev
- Children:
- 3bb1377
- Parents:
- b499ba7 (diff), 45cf412 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 62 added
- 1 deleted
- 44 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
src/Clients/Angular/finki-chattery/src/app/app-routing.module.ts
rb499ba7 rdd731cd 1 1 import { NgModule } from '@angular/core'; 2 2 import { Routes, RouterModule } from '@angular/router'; 3 import { AuthorizedGuard } from './core/guards/authorized.guard'; 3 4 4 5 const routes: Routes = [ 5 6 { 7 path: 'questioning', 8 canActivate: [AuthorizedGuard], 9 loadChildren: () => import('./modules/questioning/questioning.module').then((x) => x.QuestioningModule) 10 }, 11 { 6 12 path: '**', 7 redirectTo: ' public/home'13 redirectTo: 'questioning/preview' 8 14 } 9 15 ]; -
src/Clients/Angular/finki-chattery/src/app/app.component.html
rb499ba7 rdd731cd 2 2 <mat-progress-bar class="global-loader" [class.hidden]="!(loader.isLoading | async)" mode="indeterminate"></mat-progress-bar> 3 3 <router-outlet></router-outlet> 4 <button (click)="login()">LOGIN</button>5 4 </main> -
src/Clients/Angular/finki-chattery/src/app/app.component.ts
rb499ba7 rdd731cd 1 1 import { Component, OnInit } from '@angular/core'; 2 import { AuthService,LoaderService, RedirectService } from './core/services';2 import { LoaderService, RedirectService } from './core/services'; 3 3 4 4 @Component({ … … 8 8 }) 9 9 export class AppComponent implements OnInit { 10 constructor(public loader: LoaderService, private redirect: RedirectService , private auth: AuthService) {}10 constructor(public loader: LoaderService, private redirect: RedirectService) {} 11 11 12 12 ngOnInit(): void { 13 13 this.redirect.redirectLoggedInUser(); 14 14 } 15 16 public login(): void {17 this.auth.login();18 }19 15 } -
src/Clients/Angular/finki-chattery/src/app/core/core.module.ts
rb499ba7 rdd731cd 14 14 import { reducers } from './state'; 15 15 import { TokenInterceptor } from './interceptors/token.interceptor'; 16 import { EffectsModule } from '@ngrx/effects'; 17 import { QuestionEffects } from './state/question-state/question.effects'; 18 import { CategoriesEffects } from './state/category-state/category.effects'; 16 19 17 20 @NgModule({ … … 33 36 maxAge: 25, 34 37 logOnly: !environment.production 35 }) 38 }), 39 EffectsModule.forRoot([QuestionEffects, CategoriesEffects]) 36 40 ], 37 41 exports: [HttpClientModule, COMPONENTS] -
src/Clients/Angular/finki-chattery/src/app/core/services/auth.service.ts
rb499ba7 rdd731cd 35 35 map((user) => { 36 36 if (user) { 37 if (user.expired) { 38 return false; 39 } 40 37 41 return true; 38 42 } -
src/Clients/Angular/finki-chattery/src/app/core/services/notification.service.ts
rb499ba7 rdd731cd 22 22 23 23 public successNotification(title: string, description?: string): void { 24 this.toastr.success(this.translate.instant(description), this.translate.instant(title)); 24 if (description) { 25 this.toastr.success(this.translate.instant(description), this.translate.instant(title)); 26 } 27 this.toastr.success(this.translate.instant(title)); 25 28 } 26 29 } -
src/Clients/Angular/finki-chattery/src/app/core/state/index.ts
rb499ba7 rdd731cd 1 1 import { ActionReducerMap } from '@ngrx/store'; 2 import { QuestionState } from './question-state/question.state'; 3 import { reducer as questionReducer } from './question-state/question.reducers'; 4 import { CategoryState } from './category-state/category.state'; 5 import { reducer as categoryReducer } from './category-state/category.reducers'; 2 6 3 export interface State {} 7 export interface State { 8 question: QuestionState; 9 category: CategoryState; 10 } 4 11 5 export const reducers: ActionReducerMap<State, any> = {}; 12 export const reducers: ActionReducerMap<State, any> = { 13 question: questionReducer, 14 category: categoryReducer 15 }; -
src/Clients/Angular/finki-chattery/src/app/shared-app/directives/directives.ts
rb499ba7 rdd731cd 1 import { HandleInputFormErrorsDirective, HoverElevationDirective, LoaderDirective, HandleSelectFormErrorsDirective } from '.'; 1 import { 2 HandleInputFormErrorsDirective, 3 HoverElevationDirective, 4 LoaderDirective, 5 HandleSelectFormErrorsDirective, 6 ShareLinkDirective 7 } from '.'; 2 8 3 9 export const DIRECTIVES: any[] = [ … … 5 11 LoaderDirective, 6 12 HoverElevationDirective, 7 HandleSelectFormErrorsDirective 13 HandleSelectFormErrorsDirective, 14 ShareLinkDirective 8 15 ]; -
src/Clients/Angular/finki-chattery/src/app/shared-app/directives/index.ts
rb499ba7 rdd731cd 3 3 export * from './hover-elevation.directive'; 4 4 export * from './handle-select-form-errors.directive'; 5 export * from './share-link.directive'; -
src/Clients/Angular/finki-chattery/src/app/shared-app/models/index.ts
rb499ba7 rdd731cd 1 1 export * from './error.models'; 2 2 export * from './user.models'; 3 export * from './question-state-view-models.models'; 4 export * from './category-state-view-models.models'; -
src/Clients/Angular/finki-chattery/src/app/shared-app/services/translate-from-json.service.ts
rb499ba7 rdd731cd 43 43 } 44 44 45 public instant(key?: string): string | undefined { 46 if (key) { 47 return this.translateService.instant(key); 48 } 49 return undefined; 45 public instant(key: string): string { 46 return this.translateService.instant(key); 50 47 } 51 48 } -
src/Clients/Angular/finki-chattery/src/app/shared-app/shared-app.module.ts
rb499ba7 rdd731cd 8 8 import { FileUploadModule } from 'ng2-file-upload'; 9 9 10 import { COMPONENTS } from './components/ generic/components';10 import { COMPONENTS } from './components/components'; 11 11 import { SharedMaterialModule } from '../shared-material/shared-material.module'; 12 12 import { DIRECTIVES } from './directives/directives'; 13 13 import { SERVICES } from './services/services'; 14 14 import { PIPES } from './pipes/pipes'; 15 import { FileUploadComponent } from './components/generic/file-upload/file-upload.component';16 import { HandleSelectFormErrorsDirective } from './directives/handle-select-form-errors.directive';17 15 18 16 @NgModule({ 19 declarations: [COMPONENTS, DIRECTIVES, PIPES , FileUploadComponent, HandleSelectFormErrorsDirective],17 declarations: [COMPONENTS, DIRECTIVES, PIPES], 20 18 providers: [SERVICES], 21 19 imports: [ … … 39 37 COMPONENTS, 40 38 DIRECTIVES, 41 PIPES 39 PIPES, 40 SharedMaterialModule 42 41 ] 43 42 }) -
src/Clients/Angular/finki-chattery/src/app/shared-material/shared-material.module.ts
rb499ba7 rdd731cd 20 20 import { MatDatepickerModule } from '@angular/material/datepicker'; 21 21 import { MatNativeDateModule } from '@angular/material/core'; 22 import { MatChipsModule } from '@angular/material/chips'; 23 import { MatTooltipModule } from '@angular/material/tooltip'; 24 import { MatButtonToggleModule } from '@angular/material/button-toggle'; 25 22 26 @NgModule({ 23 27 imports: [ … … 40 44 MatTableModule, 41 45 MatDatepickerModule, 42 MatNativeDateModule 46 MatNativeDateModule, 47 MatChipsModule, 48 MatTooltipModule, 49 MatButtonToggleModule 43 50 ], 44 51 exports: [ … … 60 67 MatTableModule, 61 68 MatDatepickerModule, 62 MatNativeDateModule 69 MatNativeDateModule, 70 MatChipsModule, 71 MatTooltipModule, 72 MatButtonToggleModule 63 73 ] 64 74 }) -
src/Clients/Angular/finki-chattery/src/assets/translations/en.json
rb499ba7 rdd731cd 14 14 "password-not-match": "Passwords don't match", 15 15 "code-date-passed": "The code date has passed", 16 "not-found": "Not found" 16 "not-found": "Not found", 17 "question-preview-subtitle": "Asked <b>{{createdOn}}</b>, Last active <b>{{lastActive}}</b>, Viewed <b>{{views}}</b> times", 18 "share-link": "Share", 19 "share-link-success": "Successfully copied link for sharing", 20 "question-asked-by-subtitle": "Asked on: {{date}}", 21 "question-answers": "{{answerCount}} Answers", 22 "question-answered-by-subtitle": "Answered on: {{date}}", 23 "student-reputation": "{{reputation}} reputation", 24 "vote-correct-answer": "This has been accepted as the correct answer by the owner of the question", 25 "answer-sort-oldest": "Oldest", 26 "answer-sort-votes": "Votes", 27 "internet-techologies": "Internet technologies", 28 "software-engineering": "Software engineering", 29 "visual-programming": "Visual programming", 30 "operating-systems": "Operating systems" 17 31 } -
src/Clients/Angular/finki-chattery/src/styles.scss
rb499ba7 rdd731cd 264 264 265 265 .avatar-image { 266 width: 100px;267 height: 100px;266 width: 80px; 267 height: 80px; 268 268 display: block; 269 269 border-radius: 50%; -
src/FinkiChattery/FinkiChattery.Api/Controllers/v1/QuestionsController.cs
rb499ba7 rdd731cd 1 1 using FinkiChattery.Api.ApplicationServices.Authentication; 2 using FinkiChattery.Api.ApplicationServices.Questioning; 2 3 using FinkiChattery.Commands.Questioning; 3 4 using FinkiChattery.Common.Mediator.Interfaces; 4 5 using FinkiChattery.Contracts.Questioning; 6 using FinkiChattery.Queries.Questioning; 5 7 using IdentityServer4.AccessTokenValidation; 6 8 using Microsoft.AspNetCore.Authorization; 7 9 using Microsoft.AspNetCore.Mvc; 10 using System; 8 11 using System.Threading.Tasks; 9 12 … … 29 32 return Ok(); 30 33 } 34 35 [HttpGet("{questionUid:Guid}")] 36 [Authorize] 37 public async Task<IActionResult> GetQuestionState([FromRoute]Guid questionUid) 38 { 39 var questionDto = await MediatorService.SendQueryAsync(new GetQuestionStateQuery(questionUid)); 40 return Ok(questionDto.ToQuestionStateResponse()); 41 } 31 42 } 32 43 } -
src/FinkiChattery/FinkiChattery.Api/FinkiChattery.Api.csproj
rb499ba7 rdd731cd 26 26 <ProjectReference Include="..\FinkiChattery.Contracts\FinkiChattery.Contracts.csproj" /> 27 27 <ProjectReference Include="..\FinkiChattery.Persistence\FinkiChattery.Persistence.csproj" /> 28 <ProjectReference Include="..\FinkiChattery.Queries\FinkiChattery.Queries.csproj" /> 28 29 </ItemGroup> 29 30 -
src/FinkiChattery/FinkiChattery.Api/Services/RegisterServices.cs
rb499ba7 rdd731cd 9 9 using FinkiChattery.Persistence.Models; 10 10 using FinkiChattery.Persistence.Repositories; 11 using FinkiChattery.Persistence.UnitOfWork; 12 using FinkiChattery.Queries.Questioning; 11 13 using Hangfire; 12 14 using Hangfire.SqlServer; … … 29 31 services.AddScoped<IEventService, EventService>(); 30 32 services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>)); 31 services.AddMediatR(typeof(AskQuestionCommand) );33 services.AddMediatR(typeof(AskQuestionCommand), typeof(GetQuestionStateQuery)); 32 34 } 33 35 … … 100 102 } 101 103 102 public static void Add Repos(this IServiceCollection services)104 public static void AddUnitOfWork(this IServiceCollection services) 103 105 { 104 services.AddScoped<ICategoriesRepo, CategoriesRepo>(); 105 services.AddScoped<ITeamRepo, TeamRepo>(); 106 services.AddScoped<IQuestionRepo, QuestionRepo>(); 107 services.AddScoped<IStudentRepo, StudentRepo>(); 106 services.AddScoped<IUnitOfWork, UnitOfWork>(); 108 107 } 109 108 … … 143 142 services.AddScoped<IStorageService, AwsStorageService>();*/ 144 143 } 145 146 // TODO: ADD HANGFIRE AND SCAFOLD DB IN HANGFIREDB147 144 } 148 145 -
src/FinkiChattery/FinkiChattery.Api/Startup.cs
rb499ba7 rdd731cd 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
rb499ba7 rdd731cd 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
rb499ba7 rdd731cd 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
rb499ba7 rdd731cd 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
rb499ba7 rdd731cd 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.Common/Mediator/Interfaces/IMediatorService.cs
rb499ba7 rdd731cd 11 11 Task<TResponse> SendAsync<TResponse>(ICommand<TResponse> request); 12 12 13 Task<TResponse> SendQueryAsync<TResponse>(IQuery<TResponse> request, CancellationToken cancellationToken); 14 15 Task<TResponse> SendQueryAsync<TResponse>(IQuery<TResponse> request); 16 13 17 Task PublishAsync<TNotification>(TNotification notification) where TNotification : IEvent; 14 18 -
src/FinkiChattery/FinkiChattery.Common/Mediator/MediatorService.cs
rb499ba7 rdd731cd 37 37 await mediator.Publish(notification, default); 38 38 } 39 40 public async Task<TResponse> SendQueryAsync<TResponse>(IQuery<TResponse> request, CancellationToken cancellationToken) 41 { 42 return await mediator.Send(request, cancellationToken); 43 } 44 45 public async Task<TResponse> SendQueryAsync<TResponse>(IQuery<TResponse> request) 46 { 47 return await mediator.Send(request); 48 } 39 49 } 40 50 } -
src/FinkiChattery/FinkiChattery.Database/FinkiChattery.Database.sqlproj
rb499ba7 rdd731cd 70 70 <Folder Include="dbo\Tables\Student" /> 71 71 <Folder Include="FullTextSearch" /> 72 <Folder Include="dbo\Tables\Answer" /> 73 <Folder Include="dbo\Tables\AnswerResponse" /> 74 <Folder Include="dbo\Tables\Question" /> 75 <Folder Include="dbo\Tables\QuestionCategory" /> 76 <Folder Include="Snapshots" /> 72 77 </ItemGroup> 73 78 <ItemGroup> 74 79 <Build Include="dbo\Tables\Moderator.sql" /> 75 80 <Build Include="dbo\Tables\Teacher.sql" /> 76 <Build Include="dbo\Tables\Question.sql" />77 81 <Build Include="dbo\Tables\StudentTeam.sql" /> 78 82 <Build Include="dbo\Tables\TeacherTeam.sql" /> 79 <Build Include="dbo\Tables\Answer.sql" />80 <Build Include="dbo\Tables\QuestionCategory.sql" />81 <Build Include="dbo\Tables\AnswerResponse.sql" />82 83 <Build Include="dbo\Tables\Upvote.sql" /> 83 84 <Build Include="dbo\Tables\User\AspNetRoleClaims.sql" /> … … 91 92 <Build Include="FullTextSearch\FullTextIndexQuestion.sql" /> 92 93 <Build Include="FullTextSearch\QuestionFullTextCatalog.sql" /> 94 <Build Include="dbo\Tables\Question\Question.sql" /> 95 <None Include="dbo\Tables\Question\Question.Debug.Seed.sql" /> 96 <Build Include="dbo\Tables\Answer\Answer.sql" /> 97 <None Include="dbo\Tables\Answer\Answer.Debug.Seed.sql" /> 98 <Build Include="dbo\Tables\AnswerResponse\AnswerResponse.sql" /> 99 <None Include="dbo\Tables\AnswerResponse\AnswerResponse.Debug.Seed.sql" /> 100 <Build Include="dbo\Tables\QuestionCategory\QuestionCategory.sql" /> 101 <None Include="dbo\Tables\QuestionCategory\QuestionCategory.Debug.Seed.sql" /> 93 102 </ItemGroup> 94 103 <ItemGroup> … … 97 106 <PreDeploy Include="dbo\Scripts\Script.PreDeployment.sql" /> 98 107 <None Include="FinkiChattery.Database.publish.xml" /> 108 <None Include="Snapshots\FinkiChattery.Database_20210922_17-47-58.dacpac" /> 99 109 </ItemGroup> 100 110 <ItemGroup> … … 120 130 </SqlCmdVariable> 121 131 </ItemGroup> 132 <ItemGroup> 133 <RefactorLog Include="FinkiChattery.Database.refactorlog" /> 134 </ItemGroup> 122 135 </Project> -
src/FinkiChattery/FinkiChattery.Database/FullTextSearch/FullTextIndexQuestion.sql
rb499ba7 rdd731cd 1 CREATE FULLTEXT INDEX ON [dbo].[Question] ([ Title], [Text])1 CREATE FULLTEXT INDEX ON [dbo].[Question] ([Search]) 2 2 KEY INDEX [PK_Question] ON [QuestionFullTextCatalog] 3 WITH (CHANGE_TRACKING AUTO , STOPLIST OFF)3 WITH (CHANGE_TRACKING AUTO) -
src/FinkiChattery/FinkiChattery.Database/dbo/Scripts/PostDeploymentScripts/Debug.PostDeployment.sql
rb499ba7 rdd731cd 1 :r .\..\..\Tables\User\Seed\Users.Debug.Seed.sql 2 :r .\..\..\Tables\Category\Category.Seed.sql 3 :r .\..\..\Tables\Student\Student.Debug.Seed.sql 1 :r ./../../Tables/User/Seed/Users.Debug.Seed.sql 2 :r ./../../Tables/Category/Category.Seed.sql 3 :r ./../../Tables/Student/Student.Debug.Seed.sql 4 :r ./../../Tables/Question/Question.Debug.Seed.sql 5 :r ./../../Tables/Answer/Answer.Debug.Seed.sql 6 :r ./../../Tables/AnswerResponse/AnswerResponse.Debug.Seed.sql 7 :r ./../../Tables/QuestionCategory/QuestionCategory.Debug.Seed.sql -
src/FinkiChattery/FinkiChattery.Database/dbo/Scripts/PostDeploymentScripts/Production.PostDeployment.sql
rb499ba7 rdd731cd 1 :r . \..\..\Tables\Category\Category.Seed.sql1 :r ./../../Tables/Category/Category.Seed.sql -
src/FinkiChattery/FinkiChattery.Database/dbo/Scripts/Script.PostDeployment.sql
rb499ba7 rdd731cd 4 4 PRINT 'Deploying DEBUG scripts'; 5 5 END 6 :r . \PostDeploymentScripts\Debug.PostDeployment.sql6 :r ./PostDeploymentScripts/Debug.PostDeployment.sql 7 7 BEGIN --Run scripts 8 8 PRINT 'End deploying DEBUG scripts'; … … 15 15 PRINT 'Deploying PRODUCTION scripts' 16 16 END 17 :r . \PostDeploymentScripts\Production.PostDeployment.sql17 :r ./PostDeploymentScripts/Production.PostDeployment.sql 18 18 BEGIN --Run scripts 19 19 PRINT 'End deploying PRODUCTION scripts' -
src/FinkiChattery/FinkiChattery.Database/dbo/Scripts/Script.PreDeployment.sql
rb499ba7 rdd731cd 4 4 PRINT 'Deploying DEBUG pre deployment scripts'; 5 5 END 6 :r . \PreDeploymentScripts\Debug.PreDeployment.sql6 :r ./PreDeploymentScripts/Debug.PreDeployment.sql 7 7 BEGIN --Run scripts 8 8 PRINT 'End deploying DEBUG pre deployment scripts'; … … 15 15 PRINT 'Deploying PRODUCTION pre deployment scripts' 16 16 END 17 :r . \PreDeploymentScripts\Production.PreDeployment.sql17 :r ./PreDeploymentScripts/Production.PreDeployment.sql 18 18 BEGIN --Run scripts 19 19 PRINT 'End deploying PRODUCTION pre deployment scripts' -
src/FinkiChattery/FinkiChattery.Database/dbo/Tables/Answer/Answer.sql
rb499ba7 rdd731cd 7 7 [CorrectAnswer] BIT NOT NULL, 8 8 [CreatedOn] SMALLDATETIME NOT NULL, 9 [UpvotesCount] BIGINT NOT NULL DEFAULT 0, 9 10 CONSTRAINT [PK_Answer] PRIMARY KEY CLUSTERED ([Id] ASC), 10 11 CONSTRAINT [FK_Answer_Question_QuestionFk] FOREIGN KEY ([QuestionFk]) REFERENCES [dbo].[Question] ([Id]), -
src/FinkiChattery/FinkiChattery.Database/dbo/Tables/AnswerResponse/AnswerResponse.sql
rb499ba7 rdd731cd 8 8 CONSTRAINT [PK_AnswerResponse] PRIMARY KEY CLUSTERED ([Id] ASC), 9 9 CONSTRAINT [FK_AnswerResponse_Answer_AnswerFk] FOREIGN KEY ([AnswerFk]) REFERENCES [dbo].[Answer] ([Id]), 10 CONSTRAINT [FK_AnswerResponse_Student_AnswerFk] FOREIGN KEY ([ AnswerFk]) REFERENCES [dbo].[Student] ([Id])10 CONSTRAINT [FK_AnswerResponse_Student_AnswerFk] FOREIGN KEY ([StudentFk]) REFERENCES [dbo].[Student] ([Id]) 11 11 ); 12 12 -
src/FinkiChattery/FinkiChattery.Database/dbo/Tables/Question/Question.sql
rb499ba7 rdd731cd 9 9 [Views] BIGINT DEFAULT (CONVERT([bigint],(0))) NOT NULL, 10 10 [LastActiveOn] SMALLDATETIME NOT NULL, 11 [Search] AS ([Title] + ' ' + [Text]), 11 12 CONSTRAINT [PK_Question] PRIMARY KEY CLUSTERED ([Id] ASC), 12 13 CONSTRAINT [FK_Question_Student_StudentFk] FOREIGN KEY ([StudentFk]) REFERENCES [dbo].[Student] ([Id]), -
src/FinkiChattery/FinkiChattery.Database/dbo/Tables/QuestionCategory/QuestionCategory.sql
rb499ba7 rdd731cd 5 5 [CategoryFk] BIGINT NOT NULL, 6 6 CONSTRAINT [PK_QuestionCategory] PRIMARY KEY CLUSTERED ([Id] ASC), 7 CONSTRAINT [FK_QuestionCategory_Category_ QuestionFk] FOREIGN KEY ([QuestionFk]) REFERENCES [dbo].[Category] ([Id]),7 CONSTRAINT [FK_QuestionCategory_Category_CategoryFk] FOREIGN KEY ([CategoryFk]) REFERENCES [dbo].[Category] ([Id]), 8 8 CONSTRAINT [FK_QuestionCategory_Question_QuestionFk] FOREIGN KEY ([QuestionFk]) REFERENCES [dbo].[Question] ([Id]) 9 9 ); -
src/FinkiChattery/FinkiChattery.Persistence/Configurations/AnswerConfig.cs
rb499ba7 rdd731cd 22 22 builder.Property(x => x.CorrectAnswer).HasColumnName(@"CorrectAnswer").HasColumnType("bit").IsRequired(); 23 23 builder.Property(x => x.CreatedOn).HasColumnName(@"CreatedOn").HasColumnType("smalldatetime").IsRequired(); 24 builder.Property(x => x.UpvotesCount).HasColumnName(@"UpvotesCount").HasColumnType("bigint").IsRequired().HasDefaultValue(0); 24 25 25 26 builder.HasOne(x => x.Question).WithMany(x => x.Answers).HasForeignKey(x => x.QuestionFk).OnDelete(DeleteBehavior.Restrict); -
src/FinkiChattery/FinkiChattery.Persistence/Configurations/AnswerResponseConfig.cs
rb499ba7 rdd731cd 28 28 29 29 builder.HasOne(x => x.Answer).WithMany(x => x.AnswerResponses).HasForeignKey(x => x.AnswerFk).OnDelete(DeleteBehavior.Restrict); 30 builder.HasOne(x => x.Student).WithMany().HasForeignKey(x => x. AnswerFk).OnDelete(DeleteBehavior.Restrict);30 builder.HasOne(x => x.Student).WithMany().HasForeignKey(x => x.StudentFk).OnDelete(DeleteBehavior.Restrict); 31 31 } 32 32 } -
src/FinkiChattery/FinkiChattery.Persistence/Configurations/QuestionCategoryConfig.cs
rb499ba7 rdd731cd 26 26 27 27 builder.HasOne(x => x.Question).WithMany(x => x.QuestionCategories).HasForeignKey(x => x.QuestionFk).OnDelete(DeleteBehavior.Restrict); 28 builder.HasOne(x => x.Category).WithMany().HasForeignKey(x => x. QuestionFk).OnDelete(DeleteBehavior.Restrict);28 builder.HasOne(x => x.Category).WithMany().HasForeignKey(x => x.CategoryFk).OnDelete(DeleteBehavior.Restrict); 29 29 } 30 30 } -
src/FinkiChattery/FinkiChattery.Persistence/Configurations/QuestionConfig.cs
rb499ba7 rdd731cd 24 24 builder.Property(x => x.Views).HasColumnName(@"Views").HasColumnType("bigint").IsRequired().HasDefaultValue(0); 25 25 builder.Property(x => x.LastActiveOn).HasColumnName(@"LastActiveOn").HasColumnType("smalldatetime").IsRequired(); 26 builder.Property(x => x.Search).HasColumnType(@"Search").HasColumnType("nvarchar").HasMaxLength(4000).IsRequired(); 26 27 27 28 builder.HasOne(x => x.Student).WithMany(x => x.Questions).HasForeignKey(x => x.StudentFk).OnDelete(DeleteBehavior.NoAction); -
src/FinkiChattery/FinkiChattery.Persistence/Models/Answer.cs
rb499ba7 rdd731cd 20 20 public DateTime CreatedOn { get; set; } 21 21 22 public long UpvotesCount { get; set; } 23 22 24 public virtual ICollection<Upvote> Upvotes { get; set; } 23 25 -
src/FinkiChattery/FinkiChattery.Persistence/Models/Question.cs
rb499ba7 rdd731cd 32 32 public DateTime LastActiveOn { get; set; } 33 33 34 public string Search { get; set; } 35 34 36 public virtual ICollection<Answer> Answers { get; set; } 35 37 36 38 public virtual ICollection<QuestionCategory> QuestionCategories { get; set; } 37 38 // TODO: Pole po koe ke pravime queries39 39 } 40 40 } -
src/FinkiChattery/FinkiChattery.Persistence/Repositories/Base/Repository.cs
rb499ba7 rdd731cd 8 8 namespace FinkiChattery.Persistence.Repositories 9 9 { 10 public abstract class Repository<T> where T : BaseEntity10 public abstract class Repository<T> : IRepository<T> where T : BaseEntity 11 11 { 12 12 public Repository(ApplicationDbContext dbContext) -
src/FinkiChattery/FinkiChattery.Persistence/Repositories/Contracts/ICategoriesRepo.cs
rb499ba7 rdd731cd 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
rb499ba7 rdd731cd 1 namespace FinkiChattery.Persistence.Repositories 1 using FinkiChattery.Persistence.Models; 2 using FinkiChattery.Persistence.Repositories.Contracts; 3 using System; 4 using System.Threading.Tasks; 5 6 namespace FinkiChattery.Persistence.Repositories 2 7 { 3 public interface IQuestionRepo 8 public interface IQuestionRepo : IRepository<Question> 4 9 { 10 Task<QuestionStateDto> GetQuestionState(Guid questionUid); 5 11 } 6 12 } -
src/FinkiChattery/FinkiChattery.Persistence/Repositories/Contracts/IStudentRepo.cs
rb499ba7 rdd731cd 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
rb499ba7 rdd731cd 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.Persistence/Repositories/Implementations/QuestionRepo.cs
rb499ba7 rdd731cd 1 1 using FinkiChattery.Persistence.Context; 2 2 using FinkiChattery.Persistence.Models; 3 using FinkiChattery.Persistence.Repositories.Contracts; 4 using Microsoft.EntityFrameworkCore; 5 using System; 6 using System.Linq; 7 using System.Threading.Tasks; 3 8 4 9 namespace FinkiChattery.Persistence.Repositories … … 9 14 { 10 15 } 16 17 public async Task<QuestionStateDto> GetQuestionState(Guid questionUid) 18 { 19 // TODO: MAYBE WRITE THIS QUERY AS SP ?? 20 var questionDto = await DbSet 21 .AsNoTracking() 22 .Include(x => x.Student) 23 .Include(x => x.Team) 24 .Include(x => x.Answers).ThenInclude(y => y.Student) 25 .Include(x => x.Answers).ThenInclude(y => y.AnswerResponses).ThenInclude(y => y.Student) 26 .Include(x => x.QuestionCategories).ThenInclude(y => y.Category) 27 .Where(x => x.Uid == questionUid) 28 .Select(x => new QuestionStateDto( 29 x.Id, 30 x.Uid, 31 x.Title, 32 x.Text, 33 x.CreatedOn, 34 x.Views, 35 x.LastActiveOn, 36 new StudentQuestionStateDto( 37 x.Student.Id, 38 x.Student.Uid, 39 x.Student.IndexNumber, 40 x.Student.ImageUrl, 41 x.Student.Reputation), 42 x.Answers.Select(y => 43 new AnswerQuestionStateDto( 44 y.Id, 45 y.Uid, 46 y.Text, 47 y.CorrectAnswer, 48 y.CreatedOn, 49 y.UpvotesCount, 50 new AnswerStudentQuestionStateDto( 51 y.Student.Id, 52 y.Student.Uid, 53 y.Student.IndexNumber, 54 y.Student.ImageUrl, 55 y.Student.Reputation), 56 y.AnswerResponses.Select(z => 57 new AnswerResponseQuestionStateDto( 58 z.Id, 59 z.Uid, 60 z.Text, 61 z.CreatedOn, 62 new AnswerResponseStudentQuestionStateDto( 63 z.Student.Id, 64 z.Student.Uid, 65 z.Student.IndexNumber, 66 z.Student.ImageUrl, 67 z.Student.Reputation))))), 68 x.QuestionCategories.Select(y => 69 new QuestionCategoryQuestionStateDto( 70 y.Id, 71 y.Uid, 72 y.Category.Name)), 73 x.Team == null ? null : new TeamQuestionStateDto( 74 x.Team.Id, 75 x.Team.Uid, 76 x.Team.Name))) 77 .FirstOrDefaultAsync(); 78 79 return questionDto; 80 } 11 81 } 12 82 } -
src/FinkiChattery/FinkiChattery.Queries/FinkiChattery.Queries.csproj
rb499ba7 rdd731cd 1 <Project Sdk="Microsoft.NET.Sdk">1 <Project Sdk="Microsoft.NET.Sdk"> 2 2 3 3 <PropertyGroup> … … 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>
Note:
See TracChangeset
for help on using the changeset viewer.