Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ezefranca committed Apr 7, 2024
2 parents 9ba78a8 + ff13df8 commit 9c72295
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 18 deletions.
148 changes: 148 additions & 0 deletions DARASA/DB/Scripts/StartupDB.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
create table CASA
(
CASAId bigint identity
constraint CASA_pk
primary key,
VAT nvarchar(50),
Logo varbinary(max)
)
go

create table Badge
(
BadgeId bigint identity
constraint Badge_pk
primary key,
Image varbinary(max) not null,
Year int not null,
CASAId bigint not null
constraint Badge_CASA_CASAId_fk
references CASA
)
go

create table CASAAdvert
(
CasaAdvertId bigint identity
constraint CASAAdvert_pk
primary key,
CASAId bigint not null
constraint CASAAdvert_CASA_CASAId_fk
references CASA,
Image varbinary(max) not null,
Active bit default 1 not null
)
go

create table Enterprise
(
Name nvarchar(500),
VAT nvarchar(50) not null,
Logo varbinary(max),
EnterpriseId bigint identity
constraint Enterprise_pk
primary key,
CASAId bigint not null
constraint Enterprise_CASA_CASAId_fk
references CASA
)
go

create table EnterpriseAdvert
(
EnterpriseAdvertId bigint identity
constraint EnterpriseAdvert_pk
primary key,
Image varbinary(max) not null,
EnterpriseId bigint not null
constraint EnterpriseAdvert_Enterprise_EnterpriseId_fk
references Enterprise,
Active bit default 1 not null
)
go

create table GameCompany
(
GameCompanyId bigint identity
constraint GameCompany_pk
primary key,
Name nvarchar(500) not null,
VAT nvarchar(50),
Logo varbinary(max),
CASAId bigint not null
constraint GameCompany_CASA_CASAId_fk
references CASA
)
go

create table Game
(
GameId bigint identity
constraint Game_pk
primary key,
Name nvarchar(500) not null,
Active bit default 1 not null,
GameCompanyId bigint not null
constraint Game_GameCompany_GameCompanyId_fk
references GameCompany
)
go

create table GameEnterpriseAdvert
(
GameEnterpriseAdvertId bigint identity
constraint GameEnterpriseAdvert_pk
primary key,
GameId bigint
constraint GameEnterpriseAdvert_Game_GameId_fk
references Game,
EnterpriseAdvertId bigint not null
constraint GameEnterpriseAdvert_EnterpriseAdvert_EnterpriseAdvertId_fk
references EnterpriseAdvert,
Date datetime not null,
Rank bigint,
CasaAdvertId bigint not null
constraint GameEnterpriseAdvert_CASAAdvert_CasaAdvertId_fk
references CASAAdvert,
AdvertImage varbinary(max)
)
go

create table GameEnterpriseAdvertAppearance
(
GameEnterpriseAdvertAppearanceId bigint identity
constraint GameEnterpriseAdvertAppearance_pk
primary key,
GameEnterpriseAdvertId bigint not null
constraint GameEnterpriseAdvertAppearance_GameEnterpriseAdvert_GameEnterpriseAdvertId_fk
references GameEnterpriseAdvert,
GameId bigint not null
constraint GameEnterpriseAdvertAppearance_Game_GameId_fk
references Game,
EnterpriseAdvertId bigint not null
constraint GameEnterpriseAdvertAppearance_EnterpriseAdvert_EnterpriseAdvertId_fk
references EnterpriseAdvert,
DateShown datetime not null
)
go

create table [User]
(
UserId bigint identity
constraint User_pk
primary key,
Username nvarchar(200) not null,
Name nvarchar(200),
CASAId bigint
constraint User_CASA_CASAId_fk
references CASA,
GameCompanyId bigint
constraint User_GameCompany_GameCompanyId_fk
references GameCompany,
EnterpriseId bigint
constraint User_Enterprise_EnterpriseId_fk
references Enterprise
)
go


18 changes: 0 additions & 18 deletions DARASA/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,6 @@
async (Darasadb db) => await db.GameEnterpriseAdvertAppearances.ToListAsync()).WithOpenApi();
app.MapGet("/users", async (Darasadb db) => await db.Users.ToListAsync()).WithOpenApi();

// app.MapGet("/weatherforecast", () =>
// {
// var forecast = Enumerable.Range(1, 5).Select(index =>
// new WeatherForecast
// (
// DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
// Random.Shared.Next(-20, 55),
// summaries[Random.Shared.Next(summaries.Length)]
// ))
// .ToArray();
// return forecast;
// })
// .WithName("GetWeatherForecast")
// .WithOpenApi();

app.Run();

record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
18 changes: 18 additions & 0 deletions DARASA/Rank.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using DARASA.DB;
using Microsoft.EntityFrameworkCore;

namespace DARASA;

public class Rank
{
public void RankMonthlyBiz(Darasadb db)
{
//TODO: Rank enterprises with the games.
// gets all enterprises that have donated to CASA (active enterprise adverts)
// gets all active games
// Ranks enterprises with the ones that haven't appeared last months adverts first (gameEnterpriseAdvertAppearence)
// ranks enterprise that have appeared after.
// if there aren't enough games for enterprises these pass to the next month as first

}
}

0 comments on commit 9c72295

Please sign in to comment.