SKE-37 getCompetitionsForCategory method
This commit is contained in:
parent
513c26f155
commit
f93499ea67
@ -1,5 +1,5 @@
|
|||||||
<div class="flex-container" id="categories-list-area">
|
<div class="flex-container" id="categories-list-area">
|
||||||
<div class="flex-item" *ngFor="let category of competitionCategoriesList">
|
<div class="flex-item" *ngFor="let category of categoriesList">
|
||||||
{{ category.name }}
|
{{ category.name }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
@ -1,6 +1,6 @@
|
|||||||
import { Component, OnInit, Injector, OnDestroy } from '@angular/core';
|
import { Component, OnInit, Injector, OnDestroy } from '@angular/core';
|
||||||
import { appModuleAnimation } from '@shared/animations/routerTransition';
|
import { appModuleAnimation } from '@shared/animations/routerTransition';
|
||||||
import { CompetitionCategoryServiceProxy, CompetitionCategoryDto } from '@shared/service-proxies/service-proxies';
|
import { CategoryServiceProxy, CategoryDto } from '@shared/service-proxies/service-proxies';
|
||||||
import { List } from 'lodash';
|
import { List } from 'lodash';
|
||||||
import { AppComponentBase } from '@shared/app-component-base';
|
import { AppComponentBase } from '@shared/app-component-base';
|
||||||
import { Subscription } from 'rxjs/Rx';
|
import { Subscription } from 'rxjs/Rx';
|
||||||
@ -13,14 +13,14 @@ import { finalize } from 'rxjs/operators';
|
|||||||
})
|
})
|
||||||
export class CategoriesListComponent extends AppComponentBase implements OnInit, OnDestroy {
|
export class CategoriesListComponent extends AppComponentBase implements OnInit, OnDestroy {
|
||||||
|
|
||||||
public competitionCategoriesList: List<CompetitionCategoryDto> = [];
|
public categoriesList: List<CategoryDto> = [];
|
||||||
public categoriesListAreaId: string = 'categories-list-area';
|
public categoriesListAreaId: string = 'categories-list-area';
|
||||||
|
|
||||||
private categoryListSubscription: Subscription;
|
private categoryListSubscription: Subscription;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
injector: Injector,
|
injector: Injector,
|
||||||
private _competitionCategoryService: CompetitionCategoryServiceProxy
|
private _categoryService: CategoryServiceProxy
|
||||||
) {
|
) {
|
||||||
super(injector);
|
super(injector);
|
||||||
}
|
}
|
||||||
@ -38,10 +38,10 @@ export class CategoriesListComponent extends AppComponentBase implements OnInit,
|
|||||||
private getCompetitionCategories(): void {
|
private getCompetitionCategories(): void {
|
||||||
this.setBusy(this.categoriesListAreaId);
|
this.setBusy(this.categoriesListAreaId);
|
||||||
|
|
||||||
this.categoryListSubscription = this._competitionCategoryService.getAllCompetitionCategories()
|
this.categoryListSubscription = this._categoryService.getAllCategories()
|
||||||
.pipe(finalize(() => { this.clearBusy(this.categoriesListAreaId); }))
|
.pipe(finalize(() => { this.clearBusy(this.categoriesListAreaId); }))
|
||||||
.subscribe((result: List<CompetitionCategoryDto>) => {
|
.subscribe((result: List<CategoryDto>) => {
|
||||||
this.competitionCategoriesList = result;
|
this.categoriesList = result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -140,7 +140,7 @@ export class AccountServiceProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CompetitionCategoryServiceProxy {
|
export class CategoryServiceProxy {
|
||||||
private http: HttpClient;
|
private http: HttpClient;
|
||||||
private baseUrl: string;
|
private baseUrl: string;
|
||||||
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;
|
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;
|
||||||
@ -153,8 +153,8 @@ export class CompetitionCategoryServiceProxy {
|
|||||||
/**
|
/**
|
||||||
* @return Success
|
* @return Success
|
||||||
*/
|
*/
|
||||||
getAllCompetitionCategories(): Observable<CompetitionCategoryDto[]> {
|
getAllCategories(): Observable<CategoryDto[]> {
|
||||||
let url_ = this.baseUrl + "/api/services/app/CompetitionCategory/GetAllCompetitionCategories";
|
let url_ = this.baseUrl + "/api/services/app/Category/GetAllCategories";
|
||||||
url_ = url_.replace(/[?&]$/, "");
|
url_ = url_.replace(/[?&]$/, "");
|
||||||
|
|
||||||
let options_ : any = {
|
let options_ : any = {
|
||||||
@ -167,20 +167,20 @@ export class CompetitionCategoryServiceProxy {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return this.http.request("get", url_, options_).pipe(_observableMergeMap((response_ : any) => {
|
return this.http.request("get", url_, options_).pipe(_observableMergeMap((response_ : any) => {
|
||||||
return this.processGetAllCompetitionCategories(response_);
|
return this.processGetAllCategories(response_);
|
||||||
})).pipe(_observableCatch((response_: any) => {
|
})).pipe(_observableCatch((response_: any) => {
|
||||||
if (response_ instanceof HttpResponseBase) {
|
if (response_ instanceof HttpResponseBase) {
|
||||||
try {
|
try {
|
||||||
return this.processGetAllCompetitionCategories(<any>response_);
|
return this.processGetAllCategories(<any>response_);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return <Observable<CompetitionCategoryDto[]>><any>_observableThrow(e);
|
return <Observable<CategoryDto[]>><any>_observableThrow(e);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
return <Observable<CompetitionCategoryDto[]>><any>_observableThrow(response_);
|
return <Observable<CategoryDto[]>><any>_observableThrow(response_);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected processGetAllCompetitionCategories(response: HttpResponseBase): Observable<CompetitionCategoryDto[]> {
|
protected processGetAllCategories(response: HttpResponseBase): Observable<CategoryDto[]> {
|
||||||
const status = response.status;
|
const status = response.status;
|
||||||
const responseBlob =
|
const responseBlob =
|
||||||
response instanceof HttpResponse ? response.body :
|
response instanceof HttpResponse ? response.body :
|
||||||
@ -194,7 +194,7 @@ export class CompetitionCategoryServiceProxy {
|
|||||||
if (resultData200 && resultData200.constructor === Array) {
|
if (resultData200 && resultData200.constructor === Array) {
|
||||||
result200 = [];
|
result200 = [];
|
||||||
for (let item of resultData200)
|
for (let item of resultData200)
|
||||||
result200.push(CompetitionCategoryDto.fromJS(item));
|
result200.push(CategoryDto.fromJS(item));
|
||||||
}
|
}
|
||||||
return _observableOf(result200);
|
return _observableOf(result200);
|
||||||
}));
|
}));
|
||||||
@ -203,7 +203,78 @@ export class CompetitionCategoryServiceProxy {
|
|||||||
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
return _observableOf<CompetitionCategoryDto[]>(<any>null);
|
return _observableOf<CategoryDto[]>(<any>null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class CompetitionCategoryServiceProxy {
|
||||||
|
private http: HttpClient;
|
||||||
|
private baseUrl: string;
|
||||||
|
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;
|
||||||
|
|
||||||
|
constructor(@Inject(HttpClient) http: HttpClient, @Optional() @Inject(API_BASE_URL) baseUrl?: string) {
|
||||||
|
this.http = http;
|
||||||
|
this.baseUrl = baseUrl ? baseUrl : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @categoryId (optional)
|
||||||
|
* @return Success
|
||||||
|
*/
|
||||||
|
getAllCompetitionsForCategory(categoryId: number | null | undefined): Observable<CompetitionDto[]> {
|
||||||
|
let url_ = this.baseUrl + "/api/services/app/CompetitionCategory/GetAllCompetitionsForCategory?";
|
||||||
|
if (categoryId !== undefined)
|
||||||
|
url_ += "categoryId=" + encodeURIComponent("" + categoryId) + "&";
|
||||||
|
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.processGetAllCompetitionsForCategory(response_);
|
||||||
|
})).pipe(_observableCatch((response_: any) => {
|
||||||
|
if (response_ instanceof HttpResponseBase) {
|
||||||
|
try {
|
||||||
|
return this.processGetAllCompetitionsForCategory(<any>response_);
|
||||||
|
} catch (e) {
|
||||||
|
return <Observable<CompetitionDto[]>><any>_observableThrow(e);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
return <Observable<CompetitionDto[]>><any>_observableThrow(response_);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected processGetAllCompetitionsForCategory(response: HttpResponseBase): Observable<CompetitionDto[]> {
|
||||||
|
const status = response.status;
|
||||||
|
const responseBlob =
|
||||||
|
response instanceof HttpResponse ? response.body :
|
||||||
|
(<any>response).error instanceof Blob ? (<any>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);
|
||||||
|
if (resultData200 && resultData200.constructor === Array) {
|
||||||
|
result200 = [];
|
||||||
|
for (let item of resultData200)
|
||||||
|
result200.push(CompetitionDto.fromJS(item));
|
||||||
|
}
|
||||||
|
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<CompetitionDto[]>(<any>null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1841,11 +1912,11 @@ export interface IRegisterOutput {
|
|||||||
canLogin: boolean | undefined;
|
canLogin: boolean | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CompetitionCategoryDto implements ICompetitionCategoryDto {
|
export class CategoryDto implements ICategoryDto {
|
||||||
name: string | undefined;
|
name: string | undefined;
|
||||||
id: number | undefined;
|
id: number | undefined;
|
||||||
|
|
||||||
constructor(data?: ICompetitionCategoryDto) {
|
constructor(data?: ICategoryDto) {
|
||||||
if (data) {
|
if (data) {
|
||||||
for (var property in data) {
|
for (var property in data) {
|
||||||
if (data.hasOwnProperty(property))
|
if (data.hasOwnProperty(property))
|
||||||
@ -1861,9 +1932,9 @@ export class CompetitionCategoryDto implements ICompetitionCategoryDto {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static fromJS(data: any): CompetitionCategoryDto {
|
static fromJS(data: any): CategoryDto {
|
||||||
data = typeof data === 'object' ? data : {};
|
data = typeof data === 'object' ? data : {};
|
||||||
let result = new CompetitionCategoryDto();
|
let result = new CategoryDto();
|
||||||
result.init(data);
|
result.init(data);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1875,19 +1946,98 @@ export class CompetitionCategoryDto implements ICompetitionCategoryDto {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
clone(): CompetitionCategoryDto {
|
clone(): CategoryDto {
|
||||||
const json = this.toJSON();
|
const json = this.toJSON();
|
||||||
let result = new CompetitionCategoryDto();
|
let result = new CategoryDto();
|
||||||
result.init(json);
|
result.init(json);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ICompetitionCategoryDto {
|
export interface ICategoryDto {
|
||||||
name: string | undefined;
|
name: string | undefined;
|
||||||
id: number | undefined;
|
id: number | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class CompetitionDto implements ICompetitionDto {
|
||||||
|
name: string | undefined;
|
||||||
|
startDate: moment.Moment | undefined;
|
||||||
|
endDate: moment.Moment | undefined;
|
||||||
|
description: string | undefined;
|
||||||
|
prize: string | undefined;
|
||||||
|
minClass: number | undefined;
|
||||||
|
maxClass: number | undefined;
|
||||||
|
creationTime: moment.Moment | undefined;
|
||||||
|
creatorName: string | undefined;
|
||||||
|
id: number | undefined;
|
||||||
|
|
||||||
|
constructor(data?: ICompetitionDto) {
|
||||||
|
if (data) {
|
||||||
|
for (var property in data) {
|
||||||
|
if (data.hasOwnProperty(property))
|
||||||
|
(<any>this)[property] = (<any>data)[property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init(data?: any) {
|
||||||
|
if (data) {
|
||||||
|
this.name = data["name"];
|
||||||
|
this.startDate = data["startDate"] ? moment(data["startDate"].toString()) : <any>undefined;
|
||||||
|
this.endDate = data["endDate"] ? moment(data["endDate"].toString()) : <any>undefined;
|
||||||
|
this.description = data["description"];
|
||||||
|
this.prize = data["prize"];
|
||||||
|
this.minClass = data["minClass"];
|
||||||
|
this.maxClass = data["maxClass"];
|
||||||
|
this.creationTime = data["creationTime"] ? moment(data["creationTime"].toString()) : <any>undefined;
|
||||||
|
this.creatorName = data["creatorName"];
|
||||||
|
this.id = data["id"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static fromJS(data: any): CompetitionDto {
|
||||||
|
data = typeof data === 'object' ? data : {};
|
||||||
|
let result = new CompetitionDto();
|
||||||
|
result.init(data);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
toJSON(data?: any) {
|
||||||
|
data = typeof data === 'object' ? data : {};
|
||||||
|
data["name"] = this.name;
|
||||||
|
data["startDate"] = this.startDate ? this.startDate.toISOString() : <any>undefined;
|
||||||
|
data["endDate"] = this.endDate ? this.endDate.toISOString() : <any>undefined;
|
||||||
|
data["description"] = this.description;
|
||||||
|
data["prize"] = this.prize;
|
||||||
|
data["minClass"] = this.minClass;
|
||||||
|
data["maxClass"] = this.maxClass;
|
||||||
|
data["creationTime"] = this.creationTime ? this.creationTime.toISOString() : <any>undefined;
|
||||||
|
data["creatorName"] = this.creatorName;
|
||||||
|
data["id"] = this.id;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
clone(): CompetitionDto {
|
||||||
|
const json = this.toJSON();
|
||||||
|
let result = new CompetitionDto();
|
||||||
|
result.init(json);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ICompetitionDto {
|
||||||
|
name: string | undefined;
|
||||||
|
startDate: moment.Moment | undefined;
|
||||||
|
endDate: moment.Moment | undefined;
|
||||||
|
description: string | undefined;
|
||||||
|
prize: string | undefined;
|
||||||
|
minClass: number | undefined;
|
||||||
|
maxClass: number | undefined;
|
||||||
|
creationTime: moment.Moment | undefined;
|
||||||
|
creatorName: string | undefined;
|
||||||
|
id: number | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
export class ChangeUiThemeInput implements IChangeUiThemeInput {
|
export class ChangeUiThemeInput implements IChangeUiThemeInput {
|
||||||
theme: string;
|
theme: string;
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import * as ApiServiceProxies from './service-proxies';
|
|||||||
ApiServiceProxies.TokenAuthServiceProxy,
|
ApiServiceProxies.TokenAuthServiceProxy,
|
||||||
ApiServiceProxies.AccountServiceProxy,
|
ApiServiceProxies.AccountServiceProxy,
|
||||||
ApiServiceProxies.ConfigurationServiceProxy,
|
ApiServiceProxies.ConfigurationServiceProxy,
|
||||||
|
ApiServiceProxies.CategoryServiceProxy,
|
||||||
ApiServiceProxies.CompetitionCategoryServiceProxy,
|
ApiServiceProxies.CompetitionCategoryServiceProxy,
|
||||||
{ provide: HTTP_INTERCEPTORS, useClass: AbpHttpInterceptor, multi: true }
|
{ provide: HTTP_INTERCEPTORS, useClass: AbpHttpInterceptor, multi: true }
|
||||||
]
|
]
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
using Abp.Authorization;
|
||||||
|
using Abp.Domain.Repositories;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using SystemKonkursow.Competition.Category.Dto;
|
||||||
|
|
||||||
|
namespace SystemKonkursow.Competition.Category
|
||||||
|
{
|
||||||
|
public class CategoryAppService : SystemKonkursowAppServiceBase
|
||||||
|
{
|
||||||
|
private readonly IRepository<Domain.Category, int> _categoryRepository;
|
||||||
|
|
||||||
|
public CategoryAppService(IRepository<Domain.Category, int> categoryRepository)
|
||||||
|
{
|
||||||
|
_categoryRepository = categoryRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
[AbpAuthorize]
|
||||||
|
public List<CategoryDto> GetAllCategories()
|
||||||
|
{
|
||||||
|
var categories = _categoryRepository.GetAll().ToList();
|
||||||
|
|
||||||
|
var mappedObjects = ObjectMapper.Map<List<CategoryDto>>(categories
|
||||||
|
.OrderBy(t => t.Name));
|
||||||
|
|
||||||
|
return mappedObjects;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
using Abp.Application.Services.Dto;
|
||||||
|
|
||||||
|
namespace SystemKonkursow.Competition.Category.Dto
|
||||||
|
{
|
||||||
|
public class CategoryDto : EntityDto<int>
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
|
||||||
|
namespace SystemKonkursow.Competition.Category.Dto
|
||||||
|
{
|
||||||
|
public class CategoryMapProfile : Profile
|
||||||
|
{
|
||||||
|
public CategoryMapProfile()
|
||||||
|
{
|
||||||
|
CreateMap<Domain.Category, CategoryDto>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using Abp.Authorization;
|
using Abp.Authorization;
|
||||||
using Abp.Domain.Repositories;
|
using Abp.Domain.Repositories;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using SystemKonkursow.Competition.CompetitionCategory.Dto;
|
using SystemKonkursow.Competition.CompetitionCategory.Dto;
|
||||||
@ -9,19 +10,24 @@ namespace SystemKonkursow.Competition.CompetitionCategory
|
|||||||
public class CompetitionCategoryAppService : SystemKonkursowAppServiceBase
|
public class CompetitionCategoryAppService : SystemKonkursowAppServiceBase
|
||||||
{
|
{
|
||||||
private readonly IRepository<Domain.CompetitionCategory, int> _competitionCategoryRepository;
|
private readonly IRepository<Domain.CompetitionCategory, int> _competitionCategoryRepository;
|
||||||
|
private readonly IRepository<Domain.Competition, long> _competitionRepository;
|
||||||
|
|
||||||
public CompetitionCategoryAppService(IRepository<Domain.CompetitionCategory, int> competitionCategoryRepository)
|
public CompetitionCategoryAppService(IRepository<Domain.CompetitionCategory, int> competitionCategoryRepository,
|
||||||
|
IRepository<Domain.Competition, long> competitionRepository)
|
||||||
{
|
{
|
||||||
_competitionCategoryRepository = competitionCategoryRepository;
|
_competitionCategoryRepository = competitionCategoryRepository;
|
||||||
|
_competitionRepository = competitionRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
[AbpAuthorize]
|
[AbpAuthorize]
|
||||||
public List<CompetitionCategoryDto> GetAllCompetitionCategories()
|
public List<CompetitionDto> GetAllCompetitionsForCategory(int categoryId)
|
||||||
{
|
{
|
||||||
var competitionCategories = _competitionCategoryRepository.GetAll().ToList();
|
var competitions = _competitionCategoryRepository.GetAll()
|
||||||
|
.Include(t => t.Competition).ThenInclude(x => x.Creator)
|
||||||
|
.Where(t => t.CategoryId == categoryId).ToList();
|
||||||
|
|
||||||
var mappedObjects = ObjectMapper.Map<List<CompetitionCategoryDto>>(competitionCategories
|
var mappedObjects = ObjectMapper.Map<List<CompetitionDto>>(competitions
|
||||||
.OrderBy(t => t.Name));
|
.OrderBy(t => t.Competition.Name));
|
||||||
|
|
||||||
return mappedObjects;
|
return mappedObjects;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
using Abp.Application.Services.Dto;
|
|
||||||
|
|
||||||
namespace SystemKonkursow.Competition.CompetitionCategory.Dto
|
|
||||||
{
|
|
||||||
public class CompetitionCategoryDto : EntityDto<int>
|
|
||||||
{
|
|
||||||
public string Name { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,7 +6,16 @@ namespace SystemKonkursow.Competition.CompetitionCategory.Dto
|
|||||||
{
|
{
|
||||||
public CompetitionCategoryMapProfile()
|
public CompetitionCategoryMapProfile()
|
||||||
{
|
{
|
||||||
CreateMap<Domain.CompetitionCategory, CompetitionCategoryDto>();
|
CreateMap<Domain.CompetitionCategory, CompetitionDto>()
|
||||||
|
.ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Competition.Name))
|
||||||
|
.ForMember(dest => dest.StartDate, opt => opt.MapFrom(src => src.Competition.StartDate))
|
||||||
|
.ForMember(dest => dest.EndDate, opt => opt.MapFrom(src => src.Competition.EndDate))
|
||||||
|
.ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.Competition.Description))
|
||||||
|
.ForMember(dest => dest.Prize, opt => opt.MapFrom(src => src.Competition.Prize))
|
||||||
|
.ForMember(dest => dest.MinClass, opt => opt.MapFrom(src => src.Competition.MinClass))
|
||||||
|
.ForMember(dest => dest.MaxClass, opt => opt.MapFrom(src => src.Competition.MaxClass))
|
||||||
|
.ForMember(dest => dest.CreationTime, opt => opt.MapFrom(src => src.Competition.CreationTime))
|
||||||
|
.ForMember(dest => dest.CreatorName, opt => opt.MapFrom(src => src.Competition.Creator.UserName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
using Abp.Application.Services.Dto;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace SystemKonkursow.Competition.CompetitionCategory.Dto
|
||||||
|
{
|
||||||
|
public class CompetitionDto : EntityDto<long>
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public DateTime StartDate { get; set; }
|
||||||
|
|
||||||
|
public DateTime EndDate { get; set; }
|
||||||
|
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
public string Prize { get; set; }
|
||||||
|
|
||||||
|
public int MinClass { get; set; }
|
||||||
|
|
||||||
|
public int MaxClass { get; set; }
|
||||||
|
|
||||||
|
public DateTime CreationTime { get; set; }
|
||||||
|
|
||||||
|
public string CreatorName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
using Abp.Domain.Entities;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace SystemKonkursow.Domain
|
||||||
|
{
|
||||||
|
[Table("Categories")]
|
||||||
|
public class Category : Entity<int>
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -15,8 +15,6 @@ namespace SystemKonkursow.Domain
|
|||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
public int CompetitionCategoryId { get; set; }
|
|
||||||
|
|
||||||
public DateTime StartDate { get; set; }
|
public DateTime StartDate { get; set; }
|
||||||
|
|
||||||
public DateTime EndDate { get; set; }
|
public DateTime EndDate { get; set; }
|
||||||
@ -25,8 +23,9 @@ namespace SystemKonkursow.Domain
|
|||||||
|
|
||||||
public string Prize { get; set; }
|
public string Prize { get; set; }
|
||||||
|
|
||||||
[ForeignKey(nameof(CompetitionCategoryId))]
|
public int MinClass { get; set; }
|
||||||
public virtual CompetitionCategory CompetitionCategory { get; set; }
|
|
||||||
|
public int MaxClass { get; set; }
|
||||||
|
|
||||||
[ForeignKey(nameof(CreatorUserId))]
|
[ForeignKey(nameof(CreatorUserId))]
|
||||||
public virtual User Creator { get; set; }
|
public virtual User Creator { get; set; }
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Abp.Domain.Entities;
|
using Abp.Domain.Entities;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace SystemKonkursow.Domain
|
namespace SystemKonkursow.Domain
|
||||||
@ -7,8 +6,15 @@ namespace SystemKonkursow.Domain
|
|||||||
[Table("CompetitionCategories")]
|
[Table("CompetitionCategories")]
|
||||||
public class CompetitionCategory : Entity<int>
|
public class CompetitionCategory : Entity<int>
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public int CategoryId { get; set; }
|
||||||
|
|
||||||
|
public long CompetitionId { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(CategoryId))]
|
||||||
|
public virtual Category Category { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(CompetitionId))]
|
||||||
|
public virtual Competition Competition { get; set; }
|
||||||
|
|
||||||
public virtual ICollection<Competition> Competitions { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,9 @@ namespace SystemKonkursow.EntityFrameworkCore.Seed
|
|||||||
CreateOneCategory("Język niemiecki");
|
CreateOneCategory("Język niemiecki");
|
||||||
CreateOneCategory("Historia");
|
CreateOneCategory("Historia");
|
||||||
CreateOneCategory("Informatyka");
|
CreateOneCategory("Informatyka");
|
||||||
|
CreateOneCategory("Muzyka");
|
||||||
|
CreateOneCategory("Plastyka");
|
||||||
|
CreateOneCategory("Religia");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,29 +39,38 @@ namespace SystemKonkursow.EntityFrameworkCore.Seed
|
|||||||
{
|
{
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
|
|
||||||
|
var exampleCategory = new Domain.Category()
|
||||||
|
{
|
||||||
|
Name = name
|
||||||
|
};
|
||||||
|
|
||||||
var competitions = new List<Domain.Competition> { };
|
var competitions = new List<Domain.Competition> { };
|
||||||
|
|
||||||
for (int competitionId = 1; competitionId < CompetitionsNumber; competitionId++)
|
for (int competitionId = 1; competitionId < CompetitionsNumber; competitionId++)
|
||||||
{
|
{
|
||||||
competitions.Add(new Domain.Competition
|
var exampleCompetition = new Domain.Competition
|
||||||
{
|
{
|
||||||
CreatorUserId = 3,
|
CreatorUserId = 3,
|
||||||
Name = name + " : konkurs nr " + competitionId,
|
Name = name + " : konkurs nr " + competitionId,
|
||||||
StartDate = new DateTime(2019, rnd.Next(1, 4), rnd.Next(1, 29)),
|
StartDate = new DateTime(2019, rnd.Next(1, 4), rnd.Next(1, 29)),
|
||||||
EndDate = new DateTime(2019, rnd.Next(4, 7), rnd.Next(1, 31)),
|
EndDate = new DateTime(2019, rnd.Next(4, 7), rnd.Next(1, 31)),
|
||||||
Description = "Opis konkursu nr " + competitionId + " z kategorii: " + name,
|
Description = "Opis konkursu nr " + competitionId + " z kategorii: " + name,
|
||||||
Prize = "Opis nagród dla konkursu nr " + competitionId + " z kategorii: " + name
|
Prize = "Opis nagród dla konkursu nr " + competitionId + " z kategorii: " + name,
|
||||||
});
|
MinClass = rnd.Next(1, 5),
|
||||||
|
MaxClass = rnd.Next(5, 9)
|
||||||
|
};
|
||||||
|
|
||||||
|
var exampleCompetitionCategory = new Domain.CompetitionCategory()
|
||||||
|
{
|
||||||
|
Category = exampleCategory,
|
||||||
|
Competition = exampleCompetition
|
||||||
|
};
|
||||||
|
|
||||||
|
_context.CompetitionCategories.Add(exampleCompetitionCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
var exampleCategory = new Domain.CompetitionCategory()
|
|
||||||
{
|
|
||||||
Name = name,
|
|
||||||
Competitions = competitions
|
|
||||||
};
|
|
||||||
|
|
||||||
_context.CompetitionCategories.Add(exampleCategory);
|
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,8 @@ namespace SystemKonkursow.EntityFrameworkCore
|
|||||||
|
|
||||||
public DbSet<Domain.CompetitionCategory> CompetitionCategories { get; set; }
|
public DbSet<Domain.CompetitionCategory> CompetitionCategories { get; set; }
|
||||||
|
|
||||||
|
public DbSet<Domain.Category> Categories { get; set; }
|
||||||
|
|
||||||
public DbSet<Domain.Competition> Competitions { get; set; }
|
public DbSet<Domain.Competition> Competitions { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1008,14 +1008,25 @@ namespace SystemKonkursow.Migrations
|
|||||||
b.ToTable("AbpUsers");
|
b.ToTable("AbpUsers");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SystemKonkursow.Domain.Category", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||||
|
|
||||||
|
b.Property<string>("Name");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Categories");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("SystemKonkursow.Domain.Competition", b =>
|
modelBuilder.Entity("SystemKonkursow.Domain.Competition", b =>
|
||||||
{
|
{
|
||||||
b.Property<long>("Id")
|
b.Property<long>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||||
|
|
||||||
b.Property<int>("CompetitionCategoryId");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreationTime");
|
b.Property<DateTime>("CreationTime");
|
||||||
|
|
||||||
b.Property<long?>("CreatorUserId");
|
b.Property<long?>("CreatorUserId");
|
||||||
@ -1034,6 +1045,10 @@ namespace SystemKonkursow.Migrations
|
|||||||
|
|
||||||
b.Property<long?>("LastModifierUserId");
|
b.Property<long?>("LastModifierUserId");
|
||||||
|
|
||||||
|
b.Property<int>("MaxClass");
|
||||||
|
|
||||||
|
b.Property<int>("MinClass");
|
||||||
|
|
||||||
b.Property<string>("Name");
|
b.Property<string>("Name");
|
||||||
|
|
||||||
b.Property<string>("Prize");
|
b.Property<string>("Prize");
|
||||||
@ -1042,8 +1057,6 @@ namespace SystemKonkursow.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("CompetitionCategoryId");
|
|
||||||
|
|
||||||
b.HasIndex("CreatorUserId");
|
b.HasIndex("CreatorUserId");
|
||||||
|
|
||||||
b.ToTable("Competitions");
|
b.ToTable("Competitions");
|
||||||
@ -1055,10 +1068,16 @@ namespace SystemKonkursow.Migrations
|
|||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||||
|
|
||||||
b.Property<string>("Name");
|
b.Property<int>("CategoryId");
|
||||||
|
|
||||||
|
b.Property<long>("CompetitionId");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CategoryId");
|
||||||
|
|
||||||
|
b.HasIndex("CompetitionId");
|
||||||
|
|
||||||
b.ToTable("CompetitionCategories");
|
b.ToTable("CompetitionCategories");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1265,16 +1284,24 @@ namespace SystemKonkursow.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("SystemKonkursow.Domain.Competition", b =>
|
modelBuilder.Entity("SystemKonkursow.Domain.Competition", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("SystemKonkursow.Domain.CompetitionCategory", "CompetitionCategory")
|
|
||||||
.WithMany("Competitions")
|
|
||||||
.HasForeignKey("CompetitionCategoryId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
|
||||||
|
|
||||||
b.HasOne("SystemKonkursow.Authorization.Users.User", "Creator")
|
b.HasOne("SystemKonkursow.Authorization.Users.User", "Creator")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("CreatorUserId");
|
.HasForeignKey("CreatorUserId");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("SystemKonkursow.Domain.CompetitionCategory", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("SystemKonkursow.Domain.Category", "Category")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CategoryId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
b.HasOne("SystemKonkursow.Domain.Competition", "Competition")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CompetitionId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("SystemKonkursow.MultiTenancy.Tenant", b =>
|
modelBuilder.Entity("SystemKonkursow.MultiTenancy.Tenant", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("SystemKonkursow.Authorization.Users.User", "CreatorUser")
|
b.HasOne("SystemKonkursow.Authorization.Users.User", "CreatorUser")
|
||||||
|
Loading…
Reference in New Issue
Block a user