Changes in / [1e33fad:b499ba7]


Ignore:
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  
    11import { NgModule } from '@angular/core';
    22import { Routes, RouterModule } from '@angular/router';
    3 import { AuthorizedGuard } from './core/guards/authorized.guard';
    43
    54const routes: Routes = [
    65  {
    7     path: 'questioning',
    8     canActivate: [AuthorizedGuard],
    9     loadChildren: () => import('./modules/questioning/questioning.module').then((x) => x.QuestioningModule)
    10   },
    11   {
    126    path: '**',
    13     redirectTo: 'questioning/preview'
     7    redirectTo: 'public/home'
    148  }
    159];
  • src/Clients/Angular/finki-chattery/src/app/app.component.html

    r1e33fad rb499ba7  
    22  <mat-progress-bar class="global-loader" [class.hidden]="!(loader.isLoading | async)" mode="indeterminate"></mat-progress-bar>
    33  <router-outlet></router-outlet>
     4  <button (click)="login()">LOGIN</button>
    45</main>
  • src/Clients/Angular/finki-chattery/src/app/app.component.ts

    r1e33fad rb499ba7  
    11import { Component, OnInit } from '@angular/core';
    2 import { LoaderService, RedirectService } from './core/services';
     2import { AuthService, LoaderService, RedirectService } from './core/services';
    33
    44@Component({
     
    88})
    99export class AppComponent implements OnInit {
    10   constructor(public loader: LoaderService, private redirect: RedirectService) {}
     10  constructor(public loader: LoaderService, private redirect: RedirectService, private auth: AuthService) {}
    1111
    1212  ngOnInit(): void {
    1313    this.redirect.redirectLoggedInUser();
    1414  }
     15
     16  public login(): void {
     17    this.auth.login();
     18  }
    1519}
  • src/Clients/Angular/finki-chattery/src/app/core/core.module.ts

    r1e33fad rb499ba7  
    1414import { reducers } from './state';
    1515import { 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';
    1916
    2017@NgModule({
     
    3633      maxAge: 25,
    3734      logOnly: !environment.production
    38     }),
    39     EffectsModule.forRoot([QuestionEffects, CategoriesEffects])
     35    })
    4036  ],
    4137  exports: [HttpClientModule, COMPONENTS]
  • src/Clients/Angular/finki-chattery/src/app/core/services/auth.service.ts

    r1e33fad rb499ba7  
    3535      map((user) => {
    3636        if (user) {
    37           if (user.expired) {
    38             return false;
    39           }
    40 
    4137          return true;
    4238        }
  • src/Clients/Angular/finki-chattery/src/app/core/services/notification.service.ts

    r1e33fad rb499ba7  
    2222
    2323  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));
    2825  }
    2926}
  • src/Clients/Angular/finki-chattery/src/app/core/state/index.ts

    r1e33fad rb499ba7  
    11import { 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';
    62
    7 export interface State {
    8   question: QuestionState;
    9   category: CategoryState;
    10 }
     3export interface State {}
    114
    12 export const reducers: ActionReducerMap<State, any> = {
    13   question: questionReducer,
    14   category: categoryReducer
    15 };
     5export 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 '.';
     1import { HandleInputFormErrorsDirective, HoverElevationDirective, LoaderDirective, HandleSelectFormErrorsDirective } from '.';
    82
    93export const DIRECTIVES: any[] = [
     
    115  LoaderDirective,
    126  HoverElevationDirective,
    13   HandleSelectFormErrorsDirective,
    14   ShareLinkDirective
     7  HandleSelectFormErrorsDirective
    158];
  • src/Clients/Angular/finki-chattery/src/app/shared-app/directives/index.ts

    r1e33fad rb499ba7  
    33export * from './hover-elevation.directive';
    44export * 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  
    11export * from './error.models';
    22export * 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  
    4343  }
    4444
    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;
    4750  }
    4851}
  • src/Clients/Angular/finki-chattery/src/app/shared-app/shared-app.module.ts

    r1e33fad rb499ba7  
    88import { FileUploadModule } from 'ng2-file-upload';
    99
    10 import { COMPONENTS } from './components/components';
     10import { COMPONENTS } from './components/generic/components';
    1111import { SharedMaterialModule } from '../shared-material/shared-material.module';
    1212import { DIRECTIVES } from './directives/directives';
    1313import { SERVICES } from './services/services';
    1414import { PIPES } from './pipes/pipes';
     15import { FileUploadComponent } from './components/generic/file-upload/file-upload.component';
     16import { HandleSelectFormErrorsDirective } from './directives/handle-select-form-errors.directive';
    1517
    1618@NgModule({
    17   declarations: [COMPONENTS, DIRECTIVES, PIPES],
     19  declarations: [COMPONENTS, DIRECTIVES, PIPES, FileUploadComponent, HandleSelectFormErrorsDirective],
    1820  providers: [SERVICES],
    1921  imports: [
     
    3739    COMPONENTS,
    3840    DIRECTIVES,
    39     PIPES,
    40     SharedMaterialModule
     41    PIPES
    4142  ]
    4243})
  • src/Clients/Angular/finki-chattery/src/app/shared-material/shared-material.module.ts

    r1e33fad rb499ba7  
    2020import { MatDatepickerModule } from '@angular/material/datepicker';
    2121import { 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 
    2622@NgModule({
    2723  imports: [
     
    4440    MatTableModule,
    4541    MatDatepickerModule,
    46     MatNativeDateModule,
    47     MatChipsModule,
    48     MatTooltipModule,
    49     MatButtonToggleModule
     42    MatNativeDateModule
    5043  ],
    5144  exports: [
     
    6760    MatTableModule,
    6861    MatDatepickerModule,
    69     MatNativeDateModule,
    70     MatChipsModule,
    71     MatTooltipModule,
    72     MatButtonToggleModule
     62    MatNativeDateModule
    7363  ]
    7464})
  • src/Clients/Angular/finki-chattery/src/assets/translations/en.json

    r1e33fad rb499ba7  
    1414  "password-not-match": "Passwords don't match",
    1515  "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"
    3117}
  • src/Clients/Angular/finki-chattery/src/styles.scss

    r1e33fad rb499ba7  
    264264
    265265.avatar-image {
    266   width: 80px;
    267   height: 80px;
     266  width: 100px;
     267  height: 100px;
    268268  display: block;
    269269  border-radius: 50%;
  • src/FinkiChattery/FinkiChattery.Api/Controllers/v1/QuestionsController.cs

    r1e33fad rb499ba7  
    11using FinkiChattery.Api.ApplicationServices.Authentication;
    2 using FinkiChattery.Api.ApplicationServices.Questioning;
    32using FinkiChattery.Commands.Questioning;
    43using FinkiChattery.Common.Mediator.Interfaces;
    54using FinkiChattery.Contracts.Questioning;
    6 using FinkiChattery.Queries.Questioning;
    75using IdentityServer4.AccessTokenValidation;
    86using Microsoft.AspNetCore.Authorization;
    97using Microsoft.AspNetCore.Mvc;
    10 using System;
    118using System.Threading.Tasks;
    129
     
    3229            return Ok();
    3330        }
    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         }
    4231    }
    4332}
  • src/FinkiChattery/FinkiChattery.Api/FinkiChattery.Api.csproj

    r1e33fad rb499ba7  
    2626    <ProjectReference Include="..\FinkiChattery.Contracts\FinkiChattery.Contracts.csproj" />
    2727    <ProjectReference Include="..\FinkiChattery.Persistence\FinkiChattery.Persistence.csproj" />
    28     <ProjectReference Include="..\FinkiChattery.Queries\FinkiChattery.Queries.csproj" />
    2928  </ItemGroup>
    3029
  • src/FinkiChattery/FinkiChattery.Api/Services/RegisterServices.cs

    r1e33fad rb499ba7  
    99using FinkiChattery.Persistence.Models;
    1010using FinkiChattery.Persistence.Repositories;
    11 using FinkiChattery.Persistence.UnitOfWork;
    12 using FinkiChattery.Queries.Questioning;
    1311using Hangfire;
    1412using Hangfire.SqlServer;
     
    3129            services.AddScoped<IEventService, EventService>();
    3230            services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
    33             services.AddMediatR(typeof(AskQuestionCommand), typeof(GetQuestionStateQuery));
     31            services.AddMediatR(typeof(AskQuestionCommand));
    3432        }
    3533
     
    102100        }
    103101
    104         public static void AddUnitOfWork(this IServiceCollection services)
     102        public static void AddRepos(this IServiceCollection services)
    105103        {
    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>();
    107108        }
    108109
     
    142143                        services.AddScoped<IStorageService, AwsStorageService>();*/
    143144        }
     145
     146        // TODO: ADD HANGFIRE AND SCAFOLD DB IN HANGFIREDB
    144147    }
    145148
  • src/FinkiChattery/FinkiChattery.Api/Startup.cs

    r1e33fad rb499ba7  
    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

    r1e33fad rb499ba7  
    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

    r1e33fad rb499ba7  
    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

    r1e33fad rb499ba7  
    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

    r1e33fad rb499ba7  
    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.Common/Mediator/Interfaces/IMediatorService.cs

    r1e33fad rb499ba7  
    1111        Task<TResponse> SendAsync<TResponse>(ICommand<TResponse> request);
    1212
    13         Task<TResponse> SendQueryAsync<TResponse>(IQuery<TResponse> request, CancellationToken cancellationToken);
    14 
    15         Task<TResponse> SendQueryAsync<TResponse>(IQuery<TResponse> request);
    16 
    1713        Task PublishAsync<TNotification>(TNotification notification) where TNotification : IEvent;
    1814
  • src/FinkiChattery/FinkiChattery.Common/Mediator/MediatorService.cs

    r1e33fad rb499ba7  
    3737            await mediator.Publish(notification, default);
    3838        }
    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         }
    4939    }
    5040}
  • src/FinkiChattery/FinkiChattery.Database/FinkiChattery.Database.sqlproj

    r1e33fad rb499ba7  
    7070    <Folder Include="dbo\Tables\Student" />
    7171    <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" />
    7772  </ItemGroup>
    7873  <ItemGroup>
    7974    <Build Include="dbo\Tables\Moderator.sql" />
    8075    <Build Include="dbo\Tables\Teacher.sql" />
     76    <Build Include="dbo\Tables\Question.sql" />
    8177    <Build Include="dbo\Tables\StudentTeam.sql" />
    8278    <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" />
    8382    <Build Include="dbo\Tables\Upvote.sql" />
    8483    <Build Include="dbo\Tables\User\AspNetRoleClaims.sql" />
     
    9291    <Build Include="FullTextSearch\FullTextIndexQuestion.sql" />
    9392    <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" />
    10293  </ItemGroup>
    10394  <ItemGroup>
     
    10697    <PreDeploy Include="dbo\Scripts\Script.PreDeployment.sql" />
    10798    <None Include="FinkiChattery.Database.publish.xml" />
    108     <None Include="Snapshots\FinkiChattery.Database_20210922_17-47-58.dacpac" />
    10999  </ItemGroup>
    110100  <ItemGroup>
     
    130120    </SqlCmdVariable>
    131121  </ItemGroup>
    132   <ItemGroup>
    133     <RefactorLog Include="FinkiChattery.Database.refactorlog" />
    134   </ItemGroup>
    135122</Project>
  • src/FinkiChattery/FinkiChattery.Database/FullTextSearch/FullTextIndexQuestion.sql

    r1e33fad rb499ba7  
    1 CREATE FULLTEXT INDEX ON [dbo].[Question] ([Search])
     1CREATE FULLTEXT INDEX ON [dbo].[Question] ([Title], [Text])
    22KEY INDEX [PK_Question] ON [QuestionFullTextCatalog]
    3 WITH (CHANGE_TRACKING AUTO)
     3WITH (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.sql
     1:r .\..\..\Tables\Category\Category.Seed.sql
  • src/FinkiChattery/FinkiChattery.Database/dbo/Scripts/Script.PostDeployment.sql

    r1e33fad rb499ba7  
    44                PRINT 'Deploying DEBUG scripts';
    55        END
    6         :r ./PostDeploymentScripts/Debug.PostDeployment.sql
     6        :r .\PostDeploymentScripts\Debug.PostDeployment.sql
    77        BEGIN --Run scripts
    88                PRINT 'End deploying DEBUG scripts';
     
    1515                PRINT 'Deploying PRODUCTION scripts'
    1616        END
    17                 :r ./PostDeploymentScripts/Production.PostDeployment.sql
     17                :r .\PostDeploymentScripts\Production.PostDeployment.sql
    1818                BEGIN --Run scripts
    1919                PRINT 'End deploying PRODUCTION scripts'
  • src/FinkiChattery/FinkiChattery.Database/dbo/Scripts/Script.PreDeployment.sql

    r1e33fad rb499ba7  
    44                PRINT 'Deploying DEBUG pre deployment scripts';
    55        END
    6         :r ./PreDeploymentScripts/Debug.PreDeployment.sql
     6        :r .\PreDeploymentScripts\Debug.PreDeployment.sql
    77        BEGIN --Run scripts
    88                PRINT 'End deploying DEBUG pre deployment scripts';
     
    1515                PRINT 'Deploying PRODUCTION pre deployment scripts'
    1616        END
    17         :r ./PreDeploymentScripts/Production.PreDeployment.sql
     17        :r .\PreDeploymentScripts\Production.PreDeployment.sql
    1818        BEGIN --Run scripts
    1919                PRINT 'End deploying PRODUCTION pre deployment scripts'
  • src/FinkiChattery/FinkiChattery.Persistence/Configurations/AnswerConfig.cs

    r1e33fad rb499ba7  
    2222            builder.Property(x => x.CorrectAnswer).HasColumnName(@"CorrectAnswer").HasColumnType("bit").IsRequired();
    2323            builder.Property(x => x.CreatedOn).HasColumnName(@"CreatedOn").HasColumnType("smalldatetime").IsRequired();
    24             builder.Property(x => x.UpvotesCount).HasColumnName(@"UpvotesCount").HasColumnType("bigint").IsRequired().HasDefaultValue(0);
    2524
    2625            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  
    2828
    2929            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);
    3131        }
    3232    }
  • src/FinkiChattery/FinkiChattery.Persistence/Configurations/QuestionCategoryConfig.cs

    r1e33fad rb499ba7  
    2626
    2727            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);
    2929        }
    3030    }
  • src/FinkiChattery/FinkiChattery.Persistence/Configurations/QuestionConfig.cs

    r1e33fad rb499ba7  
    2424            builder.Property(x => x.Views).HasColumnName(@"Views").HasColumnType("bigint").IsRequired().HasDefaultValue(0);
    2525            builder.Property(x => x.LastActiveOn).HasColumnName(@"LastActiveOn").HasColumnType("smalldatetime").IsRequired();
    26             builder.Property(x => x.Search).HasColumnType(@"Search").HasColumnType("nvarchar").HasMaxLength(4000).IsRequired();
    2726
    2827            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  
    2020        public DateTime CreatedOn { get; set; }
    2121
    22         public long UpvotesCount { get; set; }
    23 
    2422        public virtual ICollection<Upvote> Upvotes { get; set; }
    2523
  • src/FinkiChattery/FinkiChattery.Persistence/Models/Question.cs

    r1e33fad rb499ba7  
    3232        public DateTime LastActiveOn { get; set; }
    3333
    34         public string Search { get; set; }
    35 
    3634        public virtual ICollection<Answer> Answers { get; set; }
    3735
    3836        public virtual ICollection<QuestionCategory> QuestionCategories { get; set; }
     37
     38        // TODO: Pole po koe ke pravime queries
    3939    }
    4040}
  • src/FinkiChattery/FinkiChattery.Persistence/Repositories/Base/Repository.cs

    r1e33fad rb499ba7  
    88namespace FinkiChattery.Persistence.Repositories
    99{
    10     public abstract class Repository<T> : IRepository<T> where T : BaseEntity
     10    public abstract class Repository<T> where T : BaseEntity
    1111    {
    1212        public Repository(ApplicationDbContext dbContext)
  • src/FinkiChattery/FinkiChattery.Persistence/Repositories/Contracts/ICategoriesRepo.cs

    r1e33fad rb499ba7  
    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

    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
     1namespace FinkiChattery.Persistence.Repositories
    72{
    8     public interface IQuestionRepo : IRepository<Question>
     3    public interface IQuestionRepo
    94    {
    10         Task<QuestionStateDto> GetQuestionState(Guid questionUid);
    115    }
    126}
  • src/FinkiChattery/FinkiChattery.Persistence/Repositories/Contracts/IStudentRepo.cs

    r1e33fad rb499ba7  
    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

    r1e33fad rb499ba7  
    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.Persistence/Repositories/Implementations/QuestionRepo.cs

    r1e33fad rb499ba7  
    11using FinkiChattery.Persistence.Context;
    22using 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;
    83
    94namespace FinkiChattery.Persistence.Repositories
     
    149        {
    1510        }
    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         }
    8111    }
    8212}
  • src/FinkiChattery/FinkiChattery.Queries/FinkiChattery.Queries.csproj

    r1e33fad rb499ba7  
    1 <Project Sdk="Microsoft.NET.Sdk">
     1<Project Sdk="Microsoft.NET.Sdk">
    22
    33  <PropertyGroup>
     
    55  </PropertyGroup>
    66
    7   <ItemGroup>
    8     <ProjectReference Include="..\FinkiChattery.Common\FinkiChattery.Common.csproj" />
    9     <ProjectReference Include="..\FinkiChattery.Persistence\FinkiChattery.Persistence.csproj" />
    10   </ItemGroup>
    11 
    127</Project>
Note: See TracChangeset for help on using the changeset viewer.