Skip to content

Commit bd3b9e0

Browse files
committed
Migrate template system
Rename project
1 parent da0b5f5 commit bd3b9e0

File tree

73 files changed

+1434
-432
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1434
-432
lines changed

DodoHack-webapi.sln

Lines changed: 0 additions & 28 deletions
This file was deleted.

Infrastructure/Data/Migrations/20210404142113_initial.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Infrastructure/Data/Migrations/20210404161632_improve.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Infrastructure/Data/Migrations/DodoHackDbContextModelSnapshot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace Infrastructure.Data.Migrations
1010
{
11-
[DbContext(typeof(DodoHackDbContext))]
11+
[DbContext(typeof(TitsDbContext))]
1212
partial class DodoHackDbContextModelSnapshot : ModelSnapshot
1313
{
1414
protected override void BuildModel(ModelBuilder modelBuilder)

Infrastructure/DodoHackDbContext.cs

Lines changed: 0 additions & 38 deletions
This file was deleted.

Infrastructure/TitsDbContext.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using System;
2+
using Microsoft.EntityFrameworkCore;
3+
using Models.Db;
4+
5+
namespace Infrastructure
6+
{
7+
public class TitsDbContext : DbContext
8+
{
9+
public TitsDbContext()
10+
{
11+
}
12+
13+
public TitsDbContext(DbContextOptions<TitsDbContext> options) : base(options)
14+
{
15+
}
16+
17+
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
18+
{
19+
if (optionsBuilder.IsConfigured) return;
20+
21+
var connectionString = Environment.GetEnvironmentVariable("CONN_STR");
22+
23+
if (connectionString == null) throw new ArgumentNullException("env:CONN_STR NOT PASSED");
24+
25+
optionsBuilder.UseNpgsql(connectionString);
26+
}
27+
28+
29+
protected override void OnModelCreating(ModelBuilder modelBuilder)
30+
{
31+
base.OnModelCreating(modelBuilder);
32+
modelBuilder.Entity<AccountToRole>().HasKey(atr => new {atr.RoleId, atr.AccountId});
33+
}
34+
35+
public DbSet<Account> Accounts { get; set; }
36+
public DbSet<AccountRole> AccountRoles { get; set; }
37+
public DbSet<AccountToRole> AccountToRoles { get; set; }
38+
public DbSet<AccountSession> AccountSessions { get; set; }
39+
40+
public DbSet<ProductCategory> ProductCategories { get; set; }
41+
42+
public DbSet<IngredientTemplate> IngredientTemplates { get; set; }
43+
public DbSet<ProductTemplate> ProductTemplates { get; set; }
44+
public DbSet<ProductPackTemplate> ProductPackTemplates { get; set; }
45+
46+
public DbSet<OrderIngredient> OrderIngredients { get; set; }
47+
public DbSet<OrderProduct> OrderProducts { get; set; }
48+
public DbSet<OrderProductPack> OrderProductPacks { get; set; }
49+
50+
public DbSet<Order> Orders { get; set; }
51+
52+
public DbSet<WorkPoint> WorkPoints { get; set; }
53+
public DbSet<WorkSession> WorkSessions { get; set; }
54+
public DbSet<WorkSessionPause> WorkSessionPauses { get; set; }
55+
public DbSet<ScheduledWorkSession> ScheduledWorkSessions { get; set; }
56+
57+
public DbSet<LatLng> LatLngs { get; set; }
58+
}
59+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System.Collections.Generic;
2+
3+
namespace Infrastructure.Verbatims
4+
{
5+
public class AccountRolesVerbatim
6+
{
7+
public const string Superuser = "Superuser";
8+
public const string Cook = "Cook";
9+
public const string CookHot = "CookHot";
10+
public const string Packer = "Packer";
11+
public const string DeliveryCashier = "DeliveryCashier";
12+
public const string Manager = "Manager";
13+
public const string Client = "Client";
14+
15+
public static Dictionary<string, string> EnToRu = new()
16+
{
17+
{Superuser, "Супер-пользователь"},
18+
{Cook, "Повар"},
19+
{CookHot, "Повар горячего цеха"},
20+
{Packer, "Упаковщик"},
21+
{DeliveryCashier, "Кассир доставки"},
22+
{Manager, "Менеджер"},
23+
{Client, "Клиент"}
24+
};
25+
26+
public static Dictionary<string, string> RuToEn = new()
27+
{
28+
{"Супер-пользователь", Superuser},
29+
{"Повар", Cook},
30+
{"Повар горячего цеха", CookHot},
31+
{"Упаковщик", Packer},
32+
{"Кассир доставки", DeliveryCashier},
33+
{"Менеджер", Manager},
34+
{"Клиент", Client}
35+
};
36+
}
37+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace Infrastructure.Verbatims
2+
{
3+
public static class MessagesVerbatim
4+
{
5+
public const string Success = "Успешно";
6+
public const string PasswordInvalid = "Неверный пароль";
7+
public const string AccountDoesntExist = "Пользователь не существует";
8+
public const string AccountNotFound = "Пользователь не найден";
9+
public const string AuthTokenMissing = "Этот метод требует передачи ключа авторизации";
10+
public const string AuthTokenExpired = "Ключ авторизации истёк";
11+
public const string AuthTokenUnknown = "Неизвестный ключ авторизации";
12+
public const string SudoAccessRequired = "Необходим доступ 'sudo'";
13+
public const string InvalidSudoKey = "Неверный ключ 'sudo'";
14+
public const string IdNotFound = "Объект с заданным ID не найден";
15+
public const string HasOpenWorkSession = "Уже есть запущенная смена, закройте её, чтобы открыть новую";
16+
public const string NoOpenWorkSession = "Пользователь в данный момент не на смене";
17+
public const string WorkSessionIsAlreadyPaused = "Смена уже приостановлена";
18+
public const string WorkSessionIsNotPaused = "Смена в данный момент не приостановлена";
19+
public const string CantClosePausedWorkSession = "Нельзя закрыть приостановленную сессию";
20+
}
21+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Collections.Generic;
2+
3+
namespace Infrastructure.Verbatims
4+
{
5+
public class ProductCategoryVerbatim
6+
{
7+
public const string CommonRoll = "CommonRoll";
8+
public const string HotRoll = "HotRoll";
9+
public const string Soup = "Soup";
10+
public const string Drink = "Drink";
11+
public const string Addition = "Addition";
12+
13+
public static Dictionary<string, string> EnToRu = new()
14+
{
15+
{CommonRoll, "Обычный ролл"},
16+
{HotRoll, "Печёный ролл"},
17+
{Soup, "Суп"},
18+
{Drink, "Напиток"},
19+
{Addition, "Допник"},
20+
};
21+
22+
public static Dictionary<string, string> RuToEn = new()
23+
{
24+
{"Обычный ролл", CommonRoll},
25+
{"Печёный ролл", HotRoll},
26+
{"Суп", Soup},
27+
{"Напиток", Drink},
28+
{"Допник", Addition},
29+
};
30+
}
31+
}

Models/Db/Account.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Collections.Generic;
2+
using System.ComponentModel.DataAnnotations.Schema;
3+
4+
namespace Models.Db
5+
{
6+
public class Account
7+
{
8+
public long Id { get; set; }
9+
10+
public string Username { get; set; }
11+
12+
public string Login { get; set; }
13+
14+
public string Password { get; set; }
15+
16+
public virtual ICollection<AccountToRole> Roles { get; set; }
17+
18+
[ForeignKey(nameof(MainWorkPoint))]
19+
public long MainWorkPointId { get; set; }
20+
21+
public virtual WorkPoint MainWorkPoint { get; set; }
22+
23+
[ForeignKey(nameof(LastWorkSession))]
24+
public long? LastWorkSessionId { get; set; }
25+
26+
public virtual WorkSession LastWorkSession { get; set; }
27+
}
28+
}

0 commit comments

Comments
 (0)