diff --git a/SystemKonkursow/4.2.1/angular/src/app/competition-detail/competition-detail.component.html b/SystemKonkursow/4.2.1/angular/src/app/competition-detail/competition-detail.component.html
index d73c5bf..4cc1990 100644
--- a/SystemKonkursow/4.2.1/angular/src/app/competition-detail/competition-detail.component.html
+++ b/SystemKonkursow/4.2.1/angular/src/app/competition-detail/competition-detail.component.html
@@ -1 +1,3 @@
-
Szczegóły konkursu
\ No newline at end of file
+
\ No newline at end of file
diff --git a/SystemKonkursow/4.2.1/angular/src/app/competition-detail/competition-detail.component.ts b/SystemKonkursow/4.2.1/angular/src/app/competition-detail/competition-detail.component.ts
index 8d9d717..94f053a 100644
--- a/SystemKonkursow/4.2.1/angular/src/app/competition-detail/competition-detail.component.ts
+++ b/SystemKonkursow/4.2.1/angular/src/app/competition-detail/competition-detail.component.ts
@@ -3,6 +3,9 @@ import { appModuleAnimation } from '@shared/animations/routerTransition';
import { AppComponentBase } from '@shared/app-component-base';
import { Subscription } from 'rxjs/Rx';
import { ActivatedRoute } from '@angular/router';
+import { mergeMap } from 'rxjs/operators';
+import { finalize } from 'rxjs/operators';
+import { CompetitionServiceProxy, CompetitionDto } from '@shared/service-proxies/service-proxies';
@Component({
templateUrl: './competition-detail.component.html',
@@ -14,19 +17,35 @@ export class CompetitionDetailComponent extends AppComponentBase implements OnIn
private paramSubscription: Subscription;
public competitionId: number;
+ public competition: CompetitionDto = null;
+ public competitionDetailAreaId: string = 'competition-detail-area';
constructor(
injector: Injector,
private route: ActivatedRoute,
+ private _competitionService: CompetitionServiceProxy,
) {
super(injector);
}
public ngOnInit() {
+ this.competition = new CompetitionDto();
+ this.getCompetition();
+ }
+
+ private getCompetition(): void {
this.paramSubscription = this.route.params
- .subscribe(params => {
+ .pipe(mergeMap(params => {
this.competitionId = +params['id'];
- console.log('competitionId: ' + this.competitionId)
+ console.log('competitionId: ' + this.competitionId);
+ this.setBusy(this.competitionDetailAreaId);
+ const competitionDetailStream = this._competitionService
+ .getCompetition(this.competitionId)
+ .pipe(finalize(() => { this.clearBusy(this.competitionDetailAreaId); }))
+ return competitionDetailStream
+ })).subscribe((result: CompetitionDto) => {
+ this.competition = result;
+ console.log(this.competition);
});
}
diff --git a/SystemKonkursow/4.2.1/angular/src/shared/service-proxies/service-proxies.ts b/SystemKonkursow/4.2.1/angular/src/shared/service-proxies/service-proxies.ts
index 58520f9..0b41014 100644
--- a/SystemKonkursow/4.2.1/angular/src/shared/service-proxies/service-proxies.ts
+++ b/SystemKonkursow/4.2.1/angular/src/shared/service-proxies/service-proxies.ts
@@ -273,6 +273,61 @@ export class CompetitionServiceProxy {
}
return _observableOf(null);
}
+
+ /**
+ * @competitionId (optional)
+ * @return Success
+ */
+ getCompetition(competitionId: number | null | undefined): Observable {
+ let url_ = this.baseUrl + "/api/services/app/Competition/GetCompetition?";
+ if (competitionId !== undefined)
+ url_ += "competitionId=" + encodeURIComponent("" + competitionId) + "&";
+ url_ = url_.replace(/[?&]$/, "");
+
+ let options_ : any = {
+ observe: "response",
+ responseType: "blob",
+ headers: new HttpHeaders({
+ "Content-Type": "application/json",
+ "Accept": "application/json"
+ })
+ };
+
+ return this.http.request("get", url_, options_).pipe(_observableMergeMap((response_ : any) => {
+ return this.processGetCompetition(response_);
+ })).pipe(_observableCatch((response_: any) => {
+ if (response_ instanceof HttpResponseBase) {
+ try {
+ return this.processGetCompetition(response_);
+ } catch (e) {
+ return >_observableThrow(e);
+ }
+ } else
+ return >_observableThrow(response_);
+ }));
+ }
+
+ protected processGetCompetition(response: HttpResponseBase): Observable {
+ const status = response.status;
+ const responseBlob =
+ response instanceof HttpResponse ? response.body :
+ (response).error instanceof Blob ? (response).error : undefined;
+
+ let _headers: any = {}; if (response.headers) { for (let key of response.headers.keys()) { _headers[key] = response.headers.get(key); }};
+ if (status === 200) {
+ return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => {
+ let result200: any = null;
+ let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
+ result200 = resultData200 ? CompetitionDto.fromJS(resultData200) : new CompetitionDto();
+ return _observableOf(result200);
+ }));
+ } else if (status !== 200 && status !== 204) {
+ return blobToText(responseBlob).pipe(_observableMergeMap(_responseText => {
+ return throwException("An unexpected server error occurred.", status, _responseText, _headers);
+ }));
+ }
+ return _observableOf(null);
+ }
}
@Injectable()
@@ -2195,6 +2250,7 @@ export class CompetitionDto implements ICompetitionDto {
maxClass: number | undefined;
creationTime: moment.Moment | undefined;
creatorName: string | undefined;
+ questions: QuestionDto[] | undefined;
id: number | undefined;
constructor(data?: ICompetitionDto) {
@@ -2217,6 +2273,11 @@ export class CompetitionDto implements ICompetitionDto {
this.maxClass = data["maxClass"];
this.creationTime = data["creationTime"] ? moment(data["creationTime"].toString()) : undefined;
this.creatorName = data["creatorName"];
+ if (data["questions"] && data["questions"].constructor === Array) {
+ this.questions = [];
+ for (let item of data["questions"])
+ this.questions.push(QuestionDto.fromJS(item));
+ }
this.id = data["id"];
}
}
@@ -2239,6 +2300,11 @@ export class CompetitionDto implements ICompetitionDto {
data["maxClass"] = this.maxClass;
data["creationTime"] = this.creationTime ? this.creationTime.toISOString() : undefined;
data["creatorName"] = this.creatorName;
+ if (this.questions && this.questions.constructor === Array) {
+ data["questions"] = [];
+ for (let item of this.questions)
+ data["questions"].push(item.toJSON());
+ }
data["id"] = this.id;
return data;
}
@@ -2261,6 +2327,125 @@ export interface ICompetitionDto {
maxClass: number | undefined;
creationTime: moment.Moment | undefined;
creatorName: string | undefined;
+ questions: QuestionDto[] | undefined;
+ id: number | undefined;
+}
+
+export class QuestionDto implements IQuestionDto {
+ name: string | undefined;
+ competitionId: number | undefined;
+ questionOptions: QuestionOptionDto[] | undefined;
+ id: number | undefined;
+
+ constructor(data?: IQuestionDto) {
+ if (data) {
+ for (var property in data) {
+ if (data.hasOwnProperty(property))
+ (this)[property] = (data)[property];
+ }
+ }
+ }
+
+ init(data?: any) {
+ if (data) {
+ this.name = data["name"];
+ this.competitionId = data["competitionId"];
+ if (data["questionOptions"] && data["questionOptions"].constructor === Array) {
+ this.questionOptions = [];
+ for (let item of data["questionOptions"])
+ this.questionOptions.push(QuestionOptionDto.fromJS(item));
+ }
+ this.id = data["id"];
+ }
+ }
+
+ static fromJS(data: any): QuestionDto {
+ data = typeof data === 'object' ? data : {};
+ let result = new QuestionDto();
+ result.init(data);
+ return result;
+ }
+
+ toJSON(data?: any) {
+ data = typeof data === 'object' ? data : {};
+ data["name"] = this.name;
+ data["competitionId"] = this.competitionId;
+ if (this.questionOptions && this.questionOptions.constructor === Array) {
+ data["questionOptions"] = [];
+ for (let item of this.questionOptions)
+ data["questionOptions"].push(item.toJSON());
+ }
+ data["id"] = this.id;
+ return data;
+ }
+
+ clone(): QuestionDto {
+ const json = this.toJSON();
+ let result = new QuestionDto();
+ result.init(json);
+ return result;
+ }
+}
+
+export interface IQuestionDto {
+ name: string | undefined;
+ competitionId: number | undefined;
+ questionOptions: QuestionOptionDto[] | undefined;
+ id: number | undefined;
+}
+
+export class QuestionOptionDto implements IQuestionOptionDto {
+ name: string | undefined;
+ questionId: number | undefined;
+ isAnswer: boolean | undefined;
+ id: number | undefined;
+
+ constructor(data?: IQuestionOptionDto) {
+ if (data) {
+ for (var property in data) {
+ if (data.hasOwnProperty(property))
+ (this)[property] = (data)[property];
+ }
+ }
+ }
+
+ init(data?: any) {
+ if (data) {
+ this.name = data["name"];
+ this.questionId = data["questionId"];
+ this.isAnswer = data["isAnswer"];
+ this.id = data["id"];
+ }
+ }
+
+ static fromJS(data: any): QuestionOptionDto {
+ data = typeof data === 'object' ? data : {};
+ let result = new QuestionOptionDto();
+ result.init(data);
+ return result;
+ }
+
+ toJSON(data?: any) {
+ data = typeof data === 'object' ? data : {};
+ data["name"] = this.name;
+ data["questionId"] = this.questionId;
+ data["isAnswer"] = this.isAnswer;
+ data["id"] = this.id;
+ return data;
+ }
+
+ clone(): QuestionOptionDto {
+ const json = this.toJSON();
+ let result = new QuestionOptionDto();
+ result.init(json);
+ return result;
+ }
+}
+
+export interface IQuestionOptionDto {
+ name: string | undefined;
+ questionId: number | undefined;
+ isAnswer: boolean | undefined;
id: number | undefined;
}
diff --git a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/CompetitionAppService.cs b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/CompetitionAppService.cs
index d04fef4..dd9e3b1 100644
--- a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/CompetitionAppService.cs
+++ b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/CompetitionAppService.cs
@@ -1,7 +1,9 @@
using Abp.Authorization;
using Abp.Domain.Repositories;
using Abp.Domain.Uow;
+using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
+using System.Linq;
using System.Threading.Tasks;
using SystemKonkursow.Competition.CompetitionCategory.Dto;
@@ -91,5 +93,20 @@ namespace SystemKonkursow.Competition.CompetitionCategory
return newCompetitionId;
}
+
+ [AbpAuthorize]
+ public CompetitionDto GetCompetition(int competitionId)
+ {
+ var competition = _competitionRepository.GetAll()
+ .Include(t => t.Creator)
+ .Include(t => t.Questions)
+ .ThenInclude(t => t.QuestionOptions)
+ .FirstOrDefault(t => t.Id == competitionId);
+
+ var mappedObject = ObjectMapper.Map(competition);
+
+ return mappedObject;
+ }
+
}
}
diff --git a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/Dto/CompetitionCategoryMapProfile.cs b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/Dto/CompetitionCategoryMapProfile.cs
index f4d6c1c..566a0d8 100644
--- a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/Dto/CompetitionCategoryMapProfile.cs
+++ b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/Dto/CompetitionCategoryMapProfile.cs
@@ -19,6 +19,9 @@ namespace SystemKonkursow.Competition.CompetitionCategory.Dto
.ForMember(dest => dest.CreatorName, opt => opt.MapFrom(src => src.Competition.Creator.UserName));
CreateMap();
+
+ CreateMap()
+ .ForMember(dest => dest.CreatorName, opt => opt.MapFrom(src => src.Creator.UserName));
}
}
}
diff --git a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/Dto/CompetitionDto.cs b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/Dto/CompetitionDto.cs
index 98f8290..a686bf3 100644
--- a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/Dto/CompetitionDto.cs
+++ b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/Dto/CompetitionDto.cs
@@ -1,5 +1,6 @@
using Abp.Application.Services.Dto;
using System;
+using System.Collections.Generic;
namespace SystemKonkursow.Competition.CompetitionCategory.Dto
{
@@ -22,5 +23,7 @@ namespace SystemKonkursow.Competition.CompetitionCategory.Dto
public DateTime CreationTime { get; set; }
public string CreatorName { get; set; }
+
+ public List Questions { get; set; }
}
}
diff --git a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/Dto/QuestionDto.cs b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/Dto/QuestionDto.cs
new file mode 100644
index 0000000..e3b9a63
--- /dev/null
+++ b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/Dto/QuestionDto.cs
@@ -0,0 +1,14 @@
+using Abp.Application.Services.Dto;
+using System.Collections.Generic;
+
+namespace SystemKonkursow.Competition.CompetitionCategory.Dto
+{
+ public class QuestionDto : EntityDto
+ {
+ public string Name { get; set; }
+
+ public long CompetitionId { get; set; }
+
+ public List QuestionOptions { get; set; }
+ }
+}
diff --git a/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/Dto/QuestionOptionDto.cs b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/Dto/QuestionOptionDto.cs
new file mode 100644
index 0000000..9474dc0
--- /dev/null
+++ b/SystemKonkursow/4.2.1/aspnet-core/src/SystemKonkursow.Application/Competition/CompetitionCategory/Dto/QuestionOptionDto.cs
@@ -0,0 +1,13 @@
+using Abp.Application.Services.Dto;
+
+namespace SystemKonkursow.Competition.CompetitionCategory.Dto
+{
+ public class QuestionOptionDto : EntityDto
+ {
+ public string Name { get; set; }
+
+ public int QuestionId { get; set; }
+
+ public bool IsAnswer { get; set; }
+ }
+}