Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

Commit

Permalink
Удалил сущность Transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
nzour committed Dec 7, 2019
1 parent f9fc9b6 commit ea4c41e
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 185 deletions.
2 changes: 1 addition & 1 deletion cli/Commands/Util/MigrationCreateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class MigrationCreateCommand : AbstractCommand
Directory.GetCurrentDirectory() + "/../../../../src/Infrastructure/NHibernate/Migration/";

private static readonly string MigrationTemplate =
Directory.GetCurrentDirectory() + "/../Commands/Util/resources/migration.template.txt";
Directory.GetCurrentDirectory() + "/../../../Commands/Util/resources/migration.template.txt";

public override void Execute(ArgumentProvider provider)
{
Expand Down
26 changes: 0 additions & 26 deletions src/Application/CQS/Transaction/GetAllTransactionsQuery.cs

This file was deleted.

28 changes: 0 additions & 28 deletions src/Application/CQS/Transaction/TransactionFilter.cs

This file was deleted.

29 changes: 0 additions & 29 deletions src/Application/CQS/Transaction/TransactionOutput.cs

This file was deleted.

14 changes: 0 additions & 14 deletions src/Application/Http/ProfileController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
using System.Threading.Tasks;
using Application.CQS.Profile;
using Application.CQS.Reservation;
using Application.CQS.Transaction;
using Application.CQS.User.Command;
using Application.CQS.User.Input;
using Common.Util;
using Microsoft.AspNetCore.Mvc;

namespace Application.Http
Expand Down Expand Up @@ -39,18 +37,6 @@ [FromQuery] ReservationsFilter filter
return query.Execute(filter);
}

[HttpGet("transactions")]
public async Task<PaginatedData<TransactionOutput>> GetCurrentUserTransactions(
[FromServices] GetAllTransactionsQuery query,
[FromQuery] TransactionFilter filter,
[FromQuery] Pagination pagination
)
{
var currentUser = await UserExtractor.ProvideUserAsync();
filter.UserId = currentUser.Id;

return query.Execute(filter, pagination);
}

[HttpPut("update-names")]
public void UpdateUserNames([FromServices] UpdateNamesCommand command, [FromBody] UpdateNamesInput input)
Expand Down
21 changes: 0 additions & 21 deletions src/Application/Http/TransctionController.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/Domain/Entities/RoomEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class RoomEntity
public RoomType RoomType { get; set; }
public int Cost { get; set; }
public ISet<UserEntity> Employees { get; protected set; } = new HashSet<UserEntity>();
public ISet<TransactionEntity> Transactions { get; protected set; } = new HashSet<TransactionEntity>();

public RoomEntity(RoomType roomType, uint cost)
{
Expand Down
26 changes: 0 additions & 26 deletions src/Domain/Entities/TransactionEntity.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/Domain/Entities/UserEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class UserEntity
public string Login { get; protected internal set; }
public string Password { get; set; }
public UserRole Role { get; protected internal set; }
public ISet<TransactionEntity> Transactions { get; protected internal set; } = new HashSet<TransactionEntity>();
public ISet<ReservationEntity> Reservations { get; protected internal set; } = new HashSet<ReservationEntity>();

public UserEntity(string firstName, string lastName, string login, string password, UserRole role)
Expand Down
1 change: 0 additions & 1 deletion src/Infrastructure/InfrastructureExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public static IServiceCollection AddEntityRepositories(this IServiceCollection s
services.AddTransient<IEntityRepository<UserEntity>, EntityRepository<UserEntity>>();
services.AddTransient<IEntityRepository<RoomEntity>, EntityRepository<RoomEntity>>();
services.AddTransient<IEntityRepository<ServiceEntity>, EntityRepository<ServiceEntity>>();
services.AddTransient<IEntityRepository<TransactionEntity>, EntityRepository<TransactionEntity>>();
services.AddTransient<IEntityRepository<ReservationEntity>, EntityRepository<ReservationEntity>>();

services.AddTransient<IUserRepository, UserRepository>();
Expand Down
2 changes: 0 additions & 2 deletions src/Infrastructure/NHibernate/Mapping/RoomMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public RoomMap()
Map(x => x.Cost).Not.Nullable();

HasMany(x => x.Employees);

HasMany(x => x.Transactions).KeyColumn("RoomId");
}
}
}
33 changes: 0 additions & 33 deletions src/Infrastructure/NHibernate/Mapping/TransactionMap.cs

This file was deleted.

3 changes: 1 addition & 2 deletions src/Infrastructure/NHibernate/Mapping/UserMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public UserMap()
Map(x => x.Role)
.CustomType<EnumStringType<UserRole>>()
.Not.Nullable();

HasMany(x => x.Transactions).KeyColumn("UserId");

HasMany(x => x.Reservations).KeyColumn("UserId");
}
}
Expand Down
61 changes: 61 additions & 0 deletions src/Infrastructure/NHibernate/Migration/Migration20191207001.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using FluentMigrator;
using static System.Data.Rule;

namespace Infrastructure.NHibernate.Migration
{
[Migration(20191207001)]
public class Migration20191207001 : FluentMigrator.Migration
{
public override void Up()
{
Delete.Table("TransactionService");
Delete.Table("Transactions");
}

public override void Down()
{
Create.Table("Transactions")
.WithColumn("Id").AsGuid().PrimaryKey()
.WithColumn("Money").AsInt32().NotNullable()
.WithColumn("CreatedAt").AsDateTime().NotNullable()
.WithColumn("UserId").AsGuid().NotNullable()
.WithColumn("RoomId").AsGuid().NotNullable();

Create.Table("TransactionService")
.WithColumn("TransactionId").AsGuid()
.WithColumn("ServiceId").AsGuid();

Create.PrimaryKey()
.OnTable("TransactionService")
.Columns("TransactionId", "ServiceId");

Create.ForeignKey("Transactions_UserId_To_Users_FK")
.FromTable("Transactions")
.ForeignColumn("UserId")
.ToTable("Users")
.PrimaryColumn("Id")
.OnDelete(Cascade);

Create.ForeignKey("Transactions_RoomId_To_Rooms_FK")
.FromTable("Transactions")
.ForeignColumn("RoomId")
.ToTable("Rooms")
.PrimaryColumn("Id")
.OnDelete(Cascade);

Create.ForeignKey("TransactionService_TransactionId_To_Transactions")
.FromTable("TransactionService")
.ForeignColumn("TransactionId")
.ToTable("Transactions")
.PrimaryColumn("Id")
.OnDelete(Cascade);

Create.ForeignKey("TransactionService_ServiceId_To_Services")
.FromTable("TransactionService")
.ForeignColumn("ServiceId")
.ToTable("Services")
.PrimaryColumn("Id")
.OnDelete(Cascade);
}
}
}

0 comments on commit ea4c41e

Please sign in to comment.