Changes in / [1e33fad:b499ba7]
- Location:
- src
- Files:
-
- 5 added
- 66 deleted
- 44 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Clients/Angular/finki-chattery/src/app/app-routing.module.ts
r1e33fad rb499ba7 1 1 import { NgModule } from '@angular/core'; 2 2 import { Routes, RouterModule } from '@angular/router'; 3 import { AuthorizedGuard } from './core/guards/authorized.guard';4 3 5 4 const routes: Routes = [ 6 5 { 7 path: 'questioning',8 canActivate: [AuthorizedGuard],9 loadChildren: () => import('./modules/questioning/questioning.module').then((x) => x.QuestioningModule)10 },11 {12 6 path: '**', 13 redirectTo: ' questioning/preview'7 redirectTo: 'public/home' 14 8 } 15 9 ]; -
src/Clients/Angular/finki-chattery/src/app/app.component.html
r1e33fad rb499ba7 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> 4 5 </main> -
src/Clients/Angular/finki-chattery/src/app/app.component.ts
r1e33fad rb499ba7 1 1 import { Component, OnInit } from '@angular/core'; 2 import { LoaderService, RedirectService } from './core/services';2 import { AuthService, 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 ) {}10 constructor(public loader: LoaderService, private redirect: RedirectService, private auth: AuthService) {} 11 11 12 12 ngOnInit(): void { 13 13 this.redirect.redirectLoggedInUser(); 14 14 } 15 16 public login(): void { 17 this.auth.login(); 18 } 15 19 } -
src/Clients/Angular/finki-chattery/src/app/core/core.module.ts
r1e33fad rb499ba7 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';19 16 20 17 @NgModule({ … … 36 33 maxAge: 25, 37 34 logOnly: !environment.production 38 }), 39 EffectsModule.forRoot([QuestionEffects, CategoriesEffects]) 35 }) 40 36 ], 41 37 exports: [HttpClientModule, COMPONENTS] -
src/Clients/Angular/finki-chattery/src/app/core/services/auth.service.ts
r1e33fad rb499ba7 35 35 map((user) => { 36 36 if (user) { 37 if (user.expired) {38 return false;39 }40 41 37 return true; 42 38 } -
src/Clients/Angular/finki-chattery/src/app/core/services/notification.service.ts
r1e33fad rb499ba7 22 22 23 23 public successNotification(title: string, description?: string): void { 24 if (description) { 25 this.toastr.success(this.translate.instant(description), this.translate.instant(title)); 26 } 27 this.toastr.success(this.translate.instant(title)); 24 this.toastr.success(this.translate.instant(description), this.translate.instant(title)); 28 25 } 29 26 } -
src/Clients/Angular/finki-chattery/src/app/core/state/index.ts
r1e33fad rb499ba7 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';6 2 7 export interface State { 8 question: QuestionState; 9 category: CategoryState; 10 } 3 export interface State {} 11 4 12 export const reducers: ActionReducerMap<State, any> = { 13 question: questionReducer, 14 category: categoryReducer 15 }; 5 export const reducers: ActionReducerMap<State, any> = {}; -
src/Clients/Angular/finki-chattery/src/app/shared-app/directives/directives.ts
r1e33fad rb499ba7 1 import { 2 HandleInputFormErrorsDirective, 3 HoverElevationDirective, 4 LoaderDirective, 5 HandleSelectFormErrorsDirective, 6 ShareLinkDirective 7 } from '.'; 1 import { HandleInputFormErrorsDirective, HoverElevationDirective, LoaderDirective, HandleSelectFormErrorsDirective } from '.'; 8 2 9 3 export const DIRECTIVES: any[] = [ … … 11 5 LoaderDirective, 12 6 HoverElevationDirective, 13 HandleSelectFormErrorsDirective, 14 ShareLinkDirective 7 HandleSelectFormErrorsDirective 15 8 ]; -
src/Clients/Angular/finki-chattery/src/app/shared-app/directives/index.ts
r1e33fad rb499ba7 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
r1e33fad rb499ba7 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
r1e33fad rb499ba7 43 43 } 44 44 45 public instant(key: string): string { 46 return this.translateService.instant(key); 45 public instant(key?: string): string | undefined { 46 if (key) { 47 return this.translateService.instant(key); 48 } 49 return undefined; 47 50 } 48 51 } -
src/Clients/Angular/finki-chattery/src/app/shared-app/shared-app.module.ts
r1e33fad rb499ba7 8 8 import { FileUploadModule } from 'ng2-file-upload'; 9 9 10 import { COMPONENTS } from './components/ components';10 import { COMPONENTS } from './components/generic/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'; 15 17 16 18 @NgModule({ 17 declarations: [COMPONENTS, DIRECTIVES, PIPES ],19 declarations: [COMPONENTS, DIRECTIVES, PIPES, FileUploadComponent, HandleSelectFormErrorsDirective], 18 20 providers: [SERVICES], 19 21 imports: [ … … 37 39 COMPONENTS, 38 40 DIRECTIVES, 39 PIPES, 40 SharedMaterialModule 41 PIPES 41 42 ] 42 43 }) -
src/Clients/Angular/finki-chattery/src/app/shared-material/shared-material.module.ts
r1e33fad rb499ba7 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 26 22 @NgModule({ 27 23 imports: [ … … 44 40 MatTableModule, 45 41 MatDatepickerModule, 46 MatNativeDateModule, 47 MatChipsModule, 48 MatTooltipModule, 49 MatButtonToggleModule 42 MatNativeDateModule 50 43 ], 51 44 exports: [ … … 67 60 MatTableModule, 68 61 MatDatepickerModule, 69 MatNativeDateModule, 70 MatChipsModule, 71 MatTooltipModule, 72 MatButtonToggleModule 62 MatNativeDateModule 73 63 ] 74 64 }) -
src/Clients/Angular/finki-chattery/src/assets/translations/en.json
r1e33fad rb499ba7 14 14 "password-not-match": "Passwords don't match", 15 15 "code-date-passed": "The code date has passed", 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" 16 "not-found": "Not found" 31 17 } -
src/Clients/Angular/finki-chattery/src/styles.scss
r1e33fad rb499ba7 264 264 265 265 .avatar-image { 266 width: 80px;267 height: 80px;266 width: 100px; 267 height: 100px; 268 268 display: block; 269 269 border-radius: 50%; -
src/FinkiChattery/FinkiChattery.Api/Controllers/v1/QuestionsController.cs
r1e33fad rb499ba7 1 1 using FinkiChattery.Api.ApplicationServices.Authentication; 2 using FinkiChattery.Api.ApplicationServices.Questioning;3 2 using FinkiChattery.Commands.Questioning; 4 3 using FinkiChattery.Common.Mediator.Interfaces; 5 4 using FinkiChattery.Contracts.Questioning; 6 using FinkiChattery.Queries.Questioning;7 5 using IdentityServer4.AccessTokenValidation; 8 6 using Microsoft.AspNetCore.Authorization; 9 7 using Microsoft.AspNetCore.Mvc; 10 using System;11 8 using System.Threading.Tasks; 12 9 … … 32 29 return Ok(); 33 30 } 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 }42 31 } 43 32 } -
src/FinkiChattery/FinkiChattery.Api/FinkiChattery.Api.csproj
r1e33fad rb499ba7 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" />29 28 </ItemGroup> 30 29 -
src/FinkiChattery/FinkiChattery.Api/Services/RegisterServices.cs
r1e33fad rb499ba7 9 9 using FinkiChattery.Persistence.Models; 10 10 using FinkiChattery.Persistence.Repositories; 11 using FinkiChattery.Persistence.UnitOfWork;12 using FinkiChattery.Queries.Questioning;13 11 using Hangfire; 14 12 using Hangfire.SqlServer; … … 31 29 services.AddScoped<IEventService, EventService>(); 32 30 services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>)); 33 services.AddMediatR(typeof(AskQuestionCommand) , typeof(GetQuestionStateQuery));31 services.AddMediatR(typeof(AskQuestionCommand)); 34 32 } 35 33 … … 102 100 } 103 101 104 public static void Add UnitOfWork(this IServiceCollection services)102 public static void AddRepos(this IServiceCollection services) 105 103 { 106 services.AddScoped<IUnitOfWork, UnitOfWork>(); 104 services.AddScoped<ICategoriesRepo, CategoriesRepo>(); 105 services.AddScoped<ITeamRepo, TeamRepo>(); 106 services.AddScoped<IQuestionRepo, QuestionRepo>(); 107 services.AddScoped<IStudentRepo, StudentRepo>(); 107 108 } 108 109 … … 142 143 services.AddScoped<IStorageService, AwsStorageService>();*/ 143 144 } 145 146 // TODO: ADD HANGFIRE AND SCAFOLD DB IN HANGFIREDB 144 147 } 145 148 -
src/FinkiChattery/FinkiChattery.Api/Startup.cs
r1e33fad rb499ba7 35 35 services.AddOriginUrlSettings(); 36 36 services.AddCurrentUser(); 37 services.Add UnitOfWork();37 services.AddRepos(); 38 38 services.AddAwsClient(Configuration); 39 39 services.AddHangfireService(Configuration); -
src/FinkiChattery/FinkiChattery.Commands/Questioning/AskQuestion/AskQuestionCommand.cs
r1e33fad rb499ba7 1 1 using FinkiChattery.Common.Mediator.Contracs; 2 2 using FinkiChattery.Common.User; 3 using FinkiChattery.Persistence.Context; 3 4 using FinkiChattery.Persistence.Models; 4 using FinkiChattery.Persistence. UnitOfWork;5 using FinkiChattery.Persistence.Repositories; 5 6 using System; 6 7 using System.Collections.Generic; … … 26 27 public class AskQuestionHandler : ICommandHandler<AskQuestionCommand, Guid> 27 28 { 28 public AskQuestionHandler( IUnitOfWork unitOfWork, ICurrentUser currentUser)29 public AskQuestionHandler(ApplicationDbContext dbContext, ICategoriesRepo categoriesRepo, IStudentRepo studentRepo, ICurrentUser currentUser) 29 30 { 30 UnitOfWork = unitOfWork; 31 DbContext = dbContext; 32 CategoriesRepo = categoriesRepo; 33 StudentRepo = studentRepo; 31 34 CurrentUser = currentUser; 32 35 } 33 36 34 public IUnitOfWork UnitOfWork { get; } 37 public ApplicationDbContext DbContext { get; } 38 public ICategoriesRepo CategoriesRepo { get; } 39 public IStudentRepo StudentRepo { get; } 35 40 public ICurrentUser CurrentUser { get; } 36 41 37 42 public async Task<Guid> Handle(AskQuestionCommand request, CancellationToken cancellationToken) 38 43 { 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); 41 46 42 47 var questionDatabaseEntity = new Question() … … 55 60 } 56 61 57 UnitOfWork.Questions.Add(questionDatabaseEntity);58 await UnitOfWork.SaveAsync();62 DbContext.Questions.Add(questionDatabaseEntity); 63 await DbContext.SaveChangesAsync(); 59 64 return questionDatabaseEntity.Uid; 60 65 } -
src/FinkiChattery/FinkiChattery.Commands/Questioning/AskQuestion/AskQuestionValidator.cs
r1e33fad rb499ba7 1 1 using FinkiChattery.Commands.Questioning.Validators; 2 using FinkiChattery.Persistence. UnitOfWork;2 using FinkiChattery.Persistence.Repositories; 3 3 using FluentValidation; 4 4 … … 7 7 public class AskQuestionValidator : AbstractValidator<AskQuestionCommand> 8 8 { 9 public AskQuestionValidator(I UnitOfWork unitOfWork)9 public AskQuestionValidator(ICategoriesRepo categoriesRepo) 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( unitOfWork));13 RuleFor(x => x.Categories).Cascade(CascadeMode.Stop).ListNotNull().SetValidator(new CategoriesUidsExist(categoriesRepo)); 14 14 } 15 15 } -
src/FinkiChattery/FinkiChattery.Commands/Questioning/Validators/CategoriesUidsExist.cs
r1e33fad rb499ba7 1 1 using FinkiChattery.Persistence.Repositories; 2 using FinkiChattery.Persistence.UnitOfWork;3 2 using FluentValidation.Validators; 4 3 using System; … … 11 10 public class CategoriesUidsExist : AsyncValidatorBase 12 11 { 13 public CategoriesUidsExist(I UnitOfWork unitOfWork)12 public CategoriesUidsExist(ICategoriesRepo categoriesRepo) 14 13 { 15 UnitOfWork = unitOfWork;14 CategoriesRepo = categoriesRepo; 16 15 } 17 16 18 public I UnitOfWork UnitOfWork{ get; }17 public ICategoriesRepo CategoriesRepo { get; } 19 18 20 19 protected override async Task<bool> IsValidAsync(PropertyValidatorContext context, CancellationToken cancellation) … … 22 21 var categoriesUids = (IEnumerable<Guid>)context.PropertyValue; 23 22 24 return await UnitOfWork.Categories.CategoriesExist(categoriesUids);23 return await CategoriesRepo.CategoriesExist(categoriesUids); 25 24 } 26 25 -
src/FinkiChattery/FinkiChattery.Commands/Questioning/Validators/TeamWithUidExist.cs
r1e33fad rb499ba7 1 using FinkiChattery.Persistence. UnitOfWork;1 using FinkiChattery.Persistence.Repositories; 2 2 using FluentValidation.Validators; 3 3 using System; … … 9 9 public class TeamWithUidExist : AsyncValidatorBase 10 10 { 11 public TeamWithUidExist(I UnitOfWork unitOfWork)11 public TeamWithUidExist(ITeamRepo teamRepo) 12 12 { 13 UnitOfWork = unitOfWork;13 TeamRepo = teamRepo; 14 14 } 15 15 16 public I UnitOfWork UnitOfWork{ get; }16 public ITeamRepo TeamRepo { 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 UnitOfWork.Teams.TeamWithUidExists(teamUid);21 return await TeamRepo.TeamWithUidExists(teamUid); 22 22 } 23 23 -
src/FinkiChattery/FinkiChattery.Common/Mediator/Interfaces/IMediatorService.cs
r1e33fad rb499ba7 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 17 13 Task PublishAsync<TNotification>(TNotification notification) where TNotification : IEvent; 18 14 -
src/FinkiChattery/FinkiChattery.Common/Mediator/MediatorService.cs
r1e33fad rb499ba7 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 }49 39 } 50 40 } -
src/FinkiChattery/FinkiChattery.Database/FinkiChattery.Database.sqlproj
r1e33fad rb499ba7 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" />77 72 </ItemGroup> 78 73 <ItemGroup> 79 74 <Build Include="dbo\Tables\Moderator.sql" /> 80 75 <Build Include="dbo\Tables\Teacher.sql" /> 76 <Build Include="dbo\Tables\Question.sql" /> 81 77 <Build Include="dbo\Tables\StudentTeam.sql" /> 82 78 <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" /> 83 82 <Build Include="dbo\Tables\Upvote.sql" /> 84 83 <Build Include="dbo\Tables\User\AspNetRoleClaims.sql" /> … … 92 91 <Build Include="FullTextSearch\FullTextIndexQuestion.sql" /> 93 92 <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" />102 93 </ItemGroup> 103 94 <ItemGroup> … … 106 97 <PreDeploy Include="dbo\Scripts\Script.PreDeployment.sql" /> 107 98 <None Include="FinkiChattery.Database.publish.xml" /> 108 <None Include="Snapshots\FinkiChattery.Database_20210922_17-47-58.dacpac" />109 99 </ItemGroup> 110 100 <ItemGroup> … … 130 120 </SqlCmdVariable> 131 121 </ItemGroup> 132 <ItemGroup>133 <RefactorLog Include="FinkiChattery.Database.refactorlog" />134 </ItemGroup>135 122 </Project> -
src/FinkiChattery/FinkiChattery.Database/FullTextSearch/FullTextIndexQuestion.sql
r1e33fad rb499ba7 1 CREATE FULLTEXT INDEX ON [dbo].[Question] ([ Search])1 CREATE FULLTEXT INDEX ON [dbo].[Question] ([Title], [Text]) 2 2 KEY INDEX [PK_Question] ON [QuestionFullTextCatalog] 3 WITH (CHANGE_TRACKING AUTO )3 WITH (CHANGE_TRACKING AUTO, STOPLIST OFF) -
src/FinkiChattery/FinkiChattery.Database/dbo/Scripts/PostDeploymentScripts/Debug.PostDeployment.sql
r1e33fad rb499ba7 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 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
r1e33fad rb499ba7 1 :r . /../../Tables/Category/Category.Seed.sql1 :r .\..\..\Tables\Category\Category.Seed.sql -
src/FinkiChattery/FinkiChattery.Database/dbo/Scripts/Script.PostDeployment.sql
r1e33fad rb499ba7 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
r1e33fad rb499ba7 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.Persistence/Configurations/AnswerConfig.cs
r1e33fad rb499ba7 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);25 24 26 25 builder.HasOne(x => x.Question).WithMany(x => x.Answers).HasForeignKey(x => x.QuestionFk).OnDelete(DeleteBehavior.Restrict); -
src/FinkiChattery/FinkiChattery.Persistence/Configurations/AnswerResponseConfig.cs
r1e33fad rb499ba7 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. StudentFk).OnDelete(DeleteBehavior.Restrict);30 builder.HasOne(x => x.Student).WithMany().HasForeignKey(x => x.AnswerFk).OnDelete(DeleteBehavior.Restrict); 31 31 } 32 32 } -
src/FinkiChattery/FinkiChattery.Persistence/Configurations/QuestionCategoryConfig.cs
r1e33fad rb499ba7 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. CategoryFk).OnDelete(DeleteBehavior.Restrict);28 builder.HasOne(x => x.Category).WithMany().HasForeignKey(x => x.QuestionFk).OnDelete(DeleteBehavior.Restrict); 29 29 } 30 30 } -
src/FinkiChattery/FinkiChattery.Persistence/Configurations/QuestionConfig.cs
r1e33fad rb499ba7 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();27 26 28 27 builder.HasOne(x => x.Student).WithMany(x => x.Questions).HasForeignKey(x => x.StudentFk).OnDelete(DeleteBehavior.NoAction); -
src/FinkiChattery/FinkiChattery.Persistence/Models/Answer.cs
r1e33fad rb499ba7 20 20 public DateTime CreatedOn { get; set; } 21 21 22 public long UpvotesCount { get; set; }23 24 22 public virtual ICollection<Upvote> Upvotes { get; set; } 25 23 -
src/FinkiChattery/FinkiChattery.Persistence/Models/Question.cs
r1e33fad rb499ba7 32 32 public DateTime LastActiveOn { get; set; } 33 33 34 public string Search { get; set; }35 36 34 public virtual ICollection<Answer> Answers { get; set; } 37 35 38 36 public virtual ICollection<QuestionCategory> QuestionCategories { get; set; } 37 38 // TODO: Pole po koe ke pravime queries 39 39 } 40 40 } -
src/FinkiChattery/FinkiChattery.Persistence/Repositories/Base/Repository.cs
r1e33fad rb499ba7 8 8 namespace FinkiChattery.Persistence.Repositories 9 9 { 10 public abstract class Repository<T> : IRepository<T>where T : BaseEntity10 public abstract class Repository<T> where T : BaseEntity 11 11 { 12 12 public Repository(ApplicationDbContext dbContext) -
src/FinkiChattery/FinkiChattery.Persistence/Repositories/Contracts/ICategoriesRepo.cs
r1e33fad rb499ba7 8 8 namespace FinkiChattery.Persistence.Repositories 9 9 { 10 public interface ICategoriesRepo : IRepository<Category>10 public interface ICategoriesRepo 11 11 { 12 12 public Task<bool> CategoriesExist(IEnumerable<Guid> categoriesUids); -
src/FinkiChattery/FinkiChattery.Persistence/Repositories/Contracts/IQuestionRepo.cs
r1e33fad rb499ba7 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 1 namespace FinkiChattery.Persistence.Repositories 7 2 { 8 public interface IQuestionRepo : IRepository<Question>3 public interface IQuestionRepo 9 4 { 10 Task<QuestionStateDto> GetQuestionState(Guid questionUid);11 5 } 12 6 } -
src/FinkiChattery/FinkiChattery.Persistence/Repositories/Contracts/IStudentRepo.cs
r1e33fad rb499ba7 4 4 namespace FinkiChattery.Persistence.Repositories 5 5 { 6 public interface IStudentRepo : IRepository<Student>6 public interface IStudentRepo 7 7 { 8 8 public Task<Student> GetStudent(long applicationUserFk); -
src/FinkiChattery/FinkiChattery.Persistence/Repositories/Contracts/ITeamRepo.cs
r1e33fad rb499ba7 1 using FinkiChattery.Persistence.Models; 2 using System; 1 using System; 3 2 using System.Threading.Tasks; 4 3 5 4 namespace FinkiChattery.Persistence.Repositories 6 5 { 7 public interface ITeamRepo : IRepository<Team>6 public interface ITeamRepo 8 7 { 9 8 public Task<bool> TeamWithUidExists(Guid teamUid); -
src/FinkiChattery/FinkiChattery.Persistence/Repositories/Implementations/QuestionRepo.cs
r1e33fad rb499ba7 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;8 3 9 4 namespace FinkiChattery.Persistence.Repositories … … 14 9 { 15 10 } 16 17 public async Task<QuestionStateDto> GetQuestionState(Guid questionUid)18 {19 // TODO: MAYBE WRITE THIS QUERY AS SP ??20 var questionDto = await DbSet21 .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 }81 11 } 82 12 } -
src/FinkiChattery/FinkiChattery.Queries/FinkiChattery.Queries.csproj
r1e33fad rb499ba7 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 12 7 </Project>
Note:
See TracChangeset
for help on using the changeset viewer.