Skip to content

Commit

Permalink
Olhaholiak/categories renaming (#181)
Browse files Browse the repository at this point in the history
* renamed entities

* migrations

* added swagger grouping

* deleted dead usings, separated the interfase
  • Loading branch information
OlhaHoliak authored Jul 1, 2021
1 parent 9f0f657 commit 255bd7a
Show file tree
Hide file tree
Showing 60 changed files with 3,199 additions and 1,794 deletions.
60 changes: 30 additions & 30 deletions Config/SQLQuery_insert test values.sql
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,16 @@ INSERT INTO [dbo].[AspNetUserRoles]
,[RoleId])
VALUES
('16575ce5-38e3-4ae7-b991-4508ed488369' --UserId (test1)
,'c2e1a3bd-bafd-4c94-bc63-d33791b6e3c8') --roleId (parent)
,'12470199-4ac1-47b3-975d-bb4dca8b8d05') --roleId (parent)

,('7604a851-66db-4236-9271-1f037ffe3a81' --UserId (test2)
,'c2e1a3bd-bafd-4c94-bc63-d33791b6e3c8') --roleId (parent)
,'12470199-4ac1-47b3-975d-bb4dca8b8d05') --roleId (parent)

,('47802b21-2fb5-435e-9057-75c43d002cef' --UserId (test3)
,'739f5d36-64da-42d9-a967-bec1695e0e61') --roleId (provider)
,'dd8cb086-4f49-407c-82d2-f835289870b5') --roleId (provider)

,('5bff5f95-1848-4c87-9846-a567aeb407ea' --UserId (test4)
,'739f5d36-64da-42d9-a967-bec1695e0e61') --roleId (provider)
,'dd8cb086-4f49-407c-82d2-f835289870b5') --roleId (provider)
GO

--====================PARENTS AND CHILDREN================================
Expand Down Expand Up @@ -240,11 +240,11 @@ INSERT INTO [dbo].[BirthCertificates]
GO

--==================== PROVIDERS AND WORKSHOPS ================================
--Categories
INSERT INTO Categories (Title, Description) VALUES ('Музика', 'Музика'), ('Танці', 'Танці'), ('Спорт', 'Спорт')
--Directions
INSERT INTO Directions (Title, Description) VALUES ('Музика', 'Музика'), ('Танці', 'Танці'), ('Спорт', 'Спорт')
GO

INSERT INTO Subcategories (Title, Description, CategoryId)
INSERT INTO Departments (Title, Description, DirectionId)
VALUES
('Народних інструментів', 'Народних інструментів', 1),
('Духових та ударних інструментів', 'Духових та ударних інструментів', 1),
Expand All @@ -253,7 +253,7 @@ VALUES
('Неолімпійські види спорту', 'Неолімпійські види спорту', 3)
GO

INSERT INTO SubSubcategories (Title, Description, SubcategoryId)
INSERT INTO Classes (Title, Description, DepartmentId)
VALUES
('Бандура', 'Клас Бандури', 1),
('Акордеон', 'Клас Акордеону', 1),
Expand Down Expand Up @@ -441,9 +441,9 @@ INSERT INTO [dbo].[Workshops]
,[IsPerMonth]
,[ProviderId]
,[AddressId]
,[CategoryId]
,[SubcategoryId]
,[SubsubcategoryId])
,[DirectionId]
,[DepartmentId]
,[ClassId])
VALUES
('Уроки аккордиону'
,'1234567890' --Phone
Expand All @@ -464,9 +464,9 @@ INSERT INTO [dbo].[Workshops]
,1 --IsPerMonth
,1 --ProviderId
,5 --AddressId
,1 --categoryId
,2 --subcategoryId
,2) --SubsubcategoryId
,1 --directionId
,2 --departmentId
,2) --classId

,('Уроки бандури'
,'1234567890' --Phone
Expand All @@ -487,9 +487,9 @@ INSERT INTO [dbo].[Workshops]
,1 --IsPerMonth
,1 --ProviderId
,6 --AddressId
,1 --categoryId
,1 --subcategoryId
,1) --SubsubcategoryId
,1 --directionId
,1 --departmentId
,1) --classId

,('Гра на барабані'
,'1234567890' --Phone
Expand All @@ -510,9 +510,9 @@ INSERT INTO [dbo].[Workshops]
,0 --IsPerMonth
,1 --ProviderId
,7 --AddressId
,1 --categoryId
,2 --subcategoryId
,3) --SubsubcategoryId
,1 --directionId
,2 --departmentId
,3) --classId

,('Уроки гри на флейті'
,'1234567890' --Phone
Expand All @@ -523,7 +523,7 @@ INSERT INTO [dbo].[Workshops]
,5 --minAge
,100 --maxAge
,2 --days per week
,0 --price
,100 --price
,'Уроки гри на флейті'
,1 --WithDisabilityOptions
,'Немає конкретних обмежень' -- disability description
Expand All @@ -533,9 +533,9 @@ INSERT INTO [dbo].[Workshops]
,0 --IsPerMonth
,1 --ProviderId
,8 --AddressId
,1 --categoryId
,2 --subcategoryId
,4) --SubsubcategoryId
,1 --directionId
,2 --departmentId
,4) --classId

,('Айкідо'
,'1234567890' --Phone
Expand All @@ -556,9 +556,9 @@ INSERT INTO [dbo].[Workshops]
,1 --IsPerMonth
,2 --ProviderId
,9 --AddressId
,3 --categoryId
,5 --subcategoryId
,9) --SubsubcategoryId
,3 --directionId
,5 --departmentId
,9) --classId

,('Плавання'
,'1234567890' --Phone
Expand All @@ -579,9 +579,9 @@ INSERT INTO [dbo].[Workshops]
,1 --IsPerMonth
,2 --ProviderId
,10 --AddressId
,3 --categoryId
,4 --subcategoryId
,7) --SubsubcategoryId
,3 --directionId
,4 --departmentId
,7) --classId
GO

--teachers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace OutOfSchool.Services.Models
{
public class Subsubcategory
public class Class
{
public long Id { get; set; }

Expand All @@ -19,8 +19,8 @@ public class Subsubcategory
public string Description { get; set; } = string.Empty;

[Required]
public long SubcategoryId { get; set; }
public long DepartmentId { get; set; }

public virtual Subcategory Subcategory { get; set; }
public virtual Department Department { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace OutOfSchool.Services.Models
{
public class Subcategory
public class Department
{
public long Id { get; set; }

Expand All @@ -17,10 +17,10 @@ public class Subcategory
public string Description { get; set; } = string.Empty;

[Required]
public long CategoryId { get; set; }
public long DirectionId { get; set; }

public virtual Category Category { get; set; }
public virtual Direction Direction { get; set; }

public virtual List<Subsubcategory> Subsubcategories { get; set; }
public virtual List<Class> Classes { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace OutOfSchool.Services.Models
{
public class Category
public class Direction
{
public long Id { get; set; }

Expand All @@ -16,6 +16,6 @@ public class Category
[MaxLength(500)]
public string Description { get; set; } = string.Empty;

public virtual List<Subcategory> Subcategories { get; set; }
public virtual List<Department> Departments { get; set; }
}
}
8 changes: 4 additions & 4 deletions OutOfSchool/OutOfSchool.DataAccess/Models/Workshop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ public class Workshop
public long AddressId { get; set; }

[Required]
public long CategoryId { get; set; }
public long DirectionId { get; set; }

[Required]
public long SubcategoryId { get; set; }
public long DepartmentId { get; set; }

[Required]
public long SubsubcategoryId { get; set; }
public long ClassId { get; set; }

public virtual Provider Provider { get; set; }

public virtual Address Address { get; set; }

public virtual Subsubcategory Subsubcategory { get; set; }
public virtual Class Class { get; set; }

public virtual List<Teacher> Teachers { get; set; }

Expand Down
6 changes: 3 additions & 3 deletions OutOfSchool/OutOfSchool.DataAccess/OutOfSchoolDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public OutOfSchoolDbContext(DbContextOptions<OutOfSchoolDbContext> options)

public DbSet<Teacher> Teachers { get; set; }

public DbSet<Subcategory> Subcategories { get; set; }
public DbSet<Department> Departments { get; set; }

public DbSet<Subsubcategory> Subsubcategories { get; set; }
public DbSet<Class> Classes { get; set; }

public DbSet<Category> Categories { get; set; }
public DbSet<Direction> Directions { get; set; }

public DbSet<SocialGroup> SocialGroups { get; set; }

Expand Down
22 changes: 22 additions & 0 deletions OutOfSchool/OutOfSchool.DataAccess/Repository/ClassRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Linq;
using OutOfSchool.Services.Models;

namespace OutOfSchool.Services.Repository
{
public class ClassRepository : EntityRepository<Class>, IClassRepository
{
private readonly OutOfSchoolDbContext db;

public ClassRepository(OutOfSchoolDbContext dbContext)
: base(dbContext)
{
db = dbContext;
}

/// <inheritdoc/>
public bool SameExists(Class entity) => db.Classes.Any(x => (x.Title == entity.Title) && (x.DepartmentId == entity.DepartmentId));

/// <inheritdoc/>
public bool DepartmentExists(long id) => db.Departments.Any(x => x.Id == id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Linq;
using OutOfSchool.Services.Models;

namespace OutOfSchool.Services.Repository
{
public class DepartmentRepository : EntityRepository<Department>, IDepartmentRepository
{
private readonly OutOfSchoolDbContext db;

public DepartmentRepository(OutOfSchoolDbContext dbContext)
: base(dbContext)
{
db = dbContext;
}

/// <inheritdoc/>
public bool SameExists(Department entity) => db.Departments.Any(x => (x.Title == entity.Title) && (x.DirectionId == entity.DirectionId));

/// <inheritdoc/>
public bool DirectionExists(long id) => db.Directions.Any(x => x.Id == id);
}
}
14 changes: 14 additions & 0 deletions OutOfSchool/OutOfSchool.DataAccess/Repository/IClassRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using OutOfSchool.Services.Models;

namespace OutOfSchool.Services.Repository
{
public interface IClassRepository : IEntityRepository<Class>, IExistable<Class>
{
/// <summary>
/// Checks entity departmentId existens.
/// </summary>
/// <param name="id">Department id.</param>
/// <returns>Bool.</returns>
bool DepartmentExists(long id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using OutOfSchool.Services.Models;

namespace OutOfSchool.Services.Repository
{
public interface IDepartmentRepository : IEntityRepository<Department>, IExistable<Department>
{
/// <summary>
/// Checks entity directionId existens.
/// </summary>
/// <param name="id">Direction id.</param>
/// <returns>Bool.</returns>
bool DirectionExists(long id);
}
}
12 changes: 12 additions & 0 deletions OutOfSchool/OutOfSchool.DataAccess/Repository/IExistable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace OutOfSchool.Services.Repository
{
public interface IExistable<in T>
{
/// <summary>
/// Checks entity elements for uniqueness.
/// </summary>
/// <param name="entity">Entity.</param>
/// <returns>Bool.</returns>
bool SameExists(T entity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace OutOfSchool.Services.Repository
{
public interface IProviderRepository : IEntityRepository<Provider>
public interface IProviderRepository : IEntityRepository<Provider>, IExistable<Provider>
{
bool Exists(Provider entity);

bool ExistsUserId(string id);
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ namespace OutOfSchool.Services.Repository
public interface IWorkshopRepository : IEntityRepository<Workshop>
{
/// <summary>
/// Checks entity subcategoryId existence.
/// Checks entity classId existence.
/// </summary>
/// <param name="id">Subcategory id.</param>
/// <returns>True if Subsubcaategory exists, otherwise false.</returns>
bool SubsubcategoryExists(long id);
/// <param name="id">Class id.</param>
/// <returns>True if Class exists, otherwise false.</returns>
bool ClassExists(long id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ProviderRepository(OutOfSchoolDbContext dbContext)
/// </summary>
/// <param name="entity">Entity.</param>
/// <returns>Bool.</returns>
public bool Exists(Provider entity) => db.Providers.Any(x => x.EdrpouIpn == entity.EdrpouIpn || x.Email == entity.Email);
public bool SameExists(Provider entity) => db.Providers.Any(x => x.EdrpouIpn == entity.EdrpouIpn || x.Email == entity.Email);

/// <summary>
/// Checks if the user is trying to create second account.
Expand Down
Loading

0 comments on commit 255bd7a

Please sign in to comment.