Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Damov committed Sep 8, 2021
1 parent 1cd8641 commit eeb1fd5
Show file tree
Hide file tree
Showing 57 changed files with 19,170 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
18 changes: 18 additions & 0 deletions docker-compose.dcproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
<PropertyGroup Label="Globals">
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Linux</DockerTargetOS>
<ProjectGuid>c46f0724-376b-45ff-b8af-5a36443261da</ProjectGuid>
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
<DockerServiceUrl>{Scheme}://localhost:{ServicePort}</DockerServiceUrl>
<DockerServiceName>api</DockerServiceName>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose.override.yml">
<DependentUpon>docker-compose.yml</DependentUpon>
</None>
<None Include="docker-compose.yml" />
<None Include=".dockerignore" />
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.4'

services:
api:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
ports:
- "80"
- "443"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '3.4'

services:
mssql_db:
image: ${DOCKER_REGISTRY-}mcr.microsoft.com/mssql/server
restart: always
environment:
SA_PASSWORD: "P@ssw0rd"
ACCEPT_EULA: "Y"
ports:
- "1433:1433"

api:
image: ${DOCKER_REGISTRY-}mcr.microsoft.com/dotnet/aspnet
environment:
- CHOKIDAR_USEPOLLING=true
build:
context: .
dockerfile: mIRC.Web/Dockerfile
volumes:
- .:/app
depends_on:
- mssql_db
16 changes: 16 additions & 0 deletions mIRC.Core/Entities/BaseModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using mIRC.Core.Interfaces;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace mIRC.Core.Entities
{
public class BaseModel<TKey> : IAuditInfo
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public TKey Id { get; set; }
public DateTime CreatedOn { get; set; }
public DateTime? ModifiedOn { get; set; }
}
}
8 changes: 8 additions & 0 deletions mIRC.Core/Enums/RoomType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace mIRC.Core.Enums
{
public enum RoomType
{
Public = 0,
Private
}
}
11 changes: 11 additions & 0 deletions mIRC.Core/Interfaces/IAuditInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace mIRC.Core.Interfaces
{
public interface IAuditInfo
{
DateTime CreatedOn { get; set; }

DateTime? ModifiedOn { get; set; }
}
}
7 changes: 7 additions & 0 deletions mIRC.Core/mIRC.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

</Project>
28 changes: 28 additions & 0 deletions mIRC.Db/DesignTimeDbContextFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using System;
using System.IO;

namespace mIRC.Db
{
public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<mIRCDbContext>
{

public mIRCDbContext CreateDbContext(string[] args)
{
string environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");

IConfigurationRoot configuration = new ConfigurationBuilder()
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../mIRC.Web"))
.AddJsonFile($"appsettings{environment}.json").Build();

var builder = new DbContextOptionsBuilder<mIRCDbContext>();
var connectionString = configuration.GetConnectionString("DefaultConnection");

builder.UseSqlServer(connectionString);

return new mIRCDbContext(builder.Options);
}
}
}
17 changes: 17 additions & 0 deletions mIRC.Db/Entities/Message.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using mIRC.Core.Entities;
using System.ComponentModel.DataAnnotations;

namespace mIRC.Db.Entities
{
public class Message : BaseModel<string>
{
[Required(AllowEmptyStrings = false)]
[MaxLength(500)]
public string Text { get; set; }

public string UserId { get; set; }
public User User { get; set; }
public string RoomId { get; set; }
public Room Room { get; set; }
}
}
14 changes: 14 additions & 0 deletions mIRC.Db/Entities/Room.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using mIRC.Core.Entities;
using mIRC.Core.Enums;
using System.Collections.Generic;

namespace mIRC.Db.Entities
{
public class Room : BaseModel<string>
{
public string Name { get; set; }
public RoomType Type { get; set; }
public ICollection<User> Users { get; set; } = new HashSet<User>();
public ICollection<Message> Messages { get; set; } = new HashSet<Message>();
}
}
16 changes: 16 additions & 0 deletions mIRC.Db/Entities/User.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Identity;
using mIRC.Core.Interfaces;
using System;
using System.Collections.Generic;

namespace mIRC.Db.Entities
{
public class User : IdentityUser, IAuditInfo
{
public DateTime CreatedOn { get; set; }
public DateTime? ModifiedOn { get; set; }

public ICollection<Room> Rooms { get; set; } = new HashSet<Room>();

}
}
Loading

0 comments on commit eeb1fd5

Please sign in to comment.