Commit 699e07e7 authored by hasan khaddour's avatar hasan khaddour

add persistence project

parent f2d225d8
using Microsoft.EntityFrameworkCore;
using PSManagement.Domain.Customers.Aggregate;
using PSManagement.Domain.Identity.Aggregate;
namespace PSManagement.Infrastructure.Persistence
{
public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions<AppDbContext> options)
: base(options)
{
}
public DbSet<User> Users { get; set; }
public DbSet<Customer> Customers { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.HasAnnotation("Relational:Collation", "Arabic_CI_AS");
modelBuilder.Entity<Customer>(builder =>
{
builder.OwnsOne(c => c.Address);
});
modelBuilder.Entity<Customer>(builder =>
{
builder.OwnsMany(c => c.ContactInfo, contactInfoBuilder =>
{
contactInfoBuilder.OwnsOne(c => c.MobileNumber);
contactInfoBuilder.OwnsOne(c => c.PhoneNumber);
});
});
}
}
}
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using PSManagement.Domain.Customers.Repositories;
using PSManagement.Domain.Identity.Repositories;
using PSManagement.Infrastructure.Persistence.Repositories.CustomerRepository;
using PSManagement.Infrastructure.Persistence.Repositories.UserRepository;
namespace PSManagement.Infrastructure.Persistence.DI
{
public static class DependencyInjection
{
public static IServiceCollection AddPersistence(this IServiceCollection services, IConfiguration configuration)
{
services.AddDbContext<AppDbContext>(options => {
options.UseSqlServer(configuration.GetConnectionString("DefaultConnection"));
});
services.AddScoped<IUsersRepository, UsersRepository>();
services.AddScoped<ICustomersRepository, CustomersReposiotry>();
return services;
}
}
}
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using PSManagement.Infrastructure.Persistence;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20240718153846_initialMigration")]
partial class initialMigration
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:Collation", "Arabic_CI_AS")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.17")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("PSManagement.Application.Contracts.Authentication.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.HasColumnType("nvarchar(max)");
b.Property<string>("Token")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
});
#pragma warning restore 612, 618
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
public partial class initialMigration : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Email = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastName = table.Column<string>(type: "nvarchar(max)", nullable: true),
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: true),
Password = table.Column<string>(type: "nvarchar(max)", nullable: true),
Token = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Users");
}
}
}
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20240721081511_IdetnityMigration")]
partial class IdetnityMigration
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:Collation", "Arabic_CI_AS")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.17")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("PSManagement.Domain.Identity.Aggregate.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<string>("HashedPassword")
.HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
});
#pragma warning restore 612, 618
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
public partial class IdetnityMigration : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Password",
table: "Users");
migrationBuilder.RenameColumn(
name: "Token",
table: "Users",
newName: "HashedPassword");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "HashedPassword",
table: "Users",
newName: "Token");
migrationBuilder.AddColumn<string>(
name: "Password",
table: "Users",
type: "nvarchar(max)",
nullable: true);
}
}
}
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using PSManagement.Infrastructure.Persistence;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20240726102138_AddCustomers")]
partial class AddCustomers
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:Collation", "Arabic_CI_AS")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.17")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("PSManagement.Domain.Customers.Aggregate.Customer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("CustomerName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Customers");
});
modelBuilder.Entity("PSManagement.Domain.Identity.Aggregate.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<string>("HashedPassword")
.HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("PSManagement.Domain.Customers.Aggregate.Customer", b =>
{
b.OwnsMany("PSManagement.Domain.Customers.Entities.ContactInfo", "ContactInfo", b1 =>
{
b1.Property<int>("CustomerId")
.HasColumnType("int");
b1.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b1.HasKey("CustomerId", "Id");
b1.ToTable("ContactInfo");
b1.WithOwner()
.HasForeignKey("CustomerId");
b1.OwnsOne("PSManagement.Domain.Customers.ValueObjects.ContactNumber", "MobileNumber", b2 =>
{
b2.Property<int>("ContactInfoCustomerId")
.HasColumnType("int");
b2.Property<int>("ContactInfoId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b2.Property<int>("Number")
.HasColumnType("int");
b2.HasKey("ContactInfoCustomerId", "ContactInfoId");
b2.ToTable("ContactInfo");
b2.WithOwner()
.HasForeignKey("ContactInfoCustomerId", "ContactInfoId");
});
b1.OwnsOne("PSManagement.Domain.Customers.ValueObjects.ContactNumber", "PhoneNumber", b2 =>
{
b2.Property<int>("ContactInfoCustomerId")
.HasColumnType("int");
b2.Property<int>("ContactInfoId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b2.Property<int>("Number")
.HasColumnType("int");
b2.HasKey("ContactInfoCustomerId", "ContactInfoId");
b2.ToTable("ContactInfo");
b2.WithOwner()
.HasForeignKey("ContactInfoCustomerId", "ContactInfoId");
});
b1.Navigation("MobileNumber");
b1.Navigation("PhoneNumber");
});
b.OwnsOne("PSManagement.Domain.Customers.ValueObjects.Address", "Address", b1 =>
{
b1.Property<int>("CustomerId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("City")
.HasColumnType("nvarchar(max)");
b1.Property<string>("StreetName")
.HasColumnType("nvarchar(max)");
b1.Property<int>("StreetNumber")
.HasColumnType("int");
b1.Property<int>("ZipCode")
.HasColumnType("int");
b1.HasKey("CustomerId");
b1.ToTable("Customers");
b1.WithOwner()
.HasForeignKey("CustomerId");
});
b.Navigation("Address");
b.Navigation("ContactInfo");
});
#pragma warning restore 612, 618
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
public partial class AddCustomers : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Customers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CustomerName = table.Column<string>(type: "nvarchar(max)", nullable: true),
Address_StreetNumber = table.Column<int>(type: "int", nullable: true),
Address_ZipCode = table.Column<int>(type: "int", nullable: true),
Address_StreetName = table.Column<string>(type: "nvarchar(max)", nullable: true),
Address_City = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Customers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ContactInfo",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CustomerId = table.Column<int>(type: "int", nullable: false),
PhoneNumber_Number = table.Column<int>(type: "int", nullable: true),
MobileNumber_Number = table.Column<int>(type: "int", nullable: true),
Email = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ContactInfo", x => new { x.CustomerId, x.Id });
table.ForeignKey(
name: "FK_ContactInfo_Customers_CustomerId",
column: x => x.CustomerId,
principalTable: "Customers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ContactInfo");
migrationBuilder.DropTable(
name: "Customers");
}
}
}
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using PSManagement.Infrastructure.Persistence;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
[DbContext(typeof(AppDbContext))]
partial class AppDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:Collation", "Arabic_CI_AS")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.17")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("PSManagement.Domain.Customers.Aggregate.Customer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("CustomerName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Customers");
});
modelBuilder.Entity("PSManagement.Domain.Identity.Aggregate.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<string>("HashedPassword")
.HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("PSManagement.Domain.Customers.Aggregate.Customer", b =>
{
b.OwnsMany("PSManagement.Domain.Customers.Entities.ContactInfo", "ContactInfo", b1 =>
{
b1.Property<int>("CustomerId")
.HasColumnType("int");
b1.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b1.HasKey("CustomerId", "Id");
b1.ToTable("ContactInfo");
b1.WithOwner()
.HasForeignKey("CustomerId");
b1.OwnsOne("PSManagement.Domain.Customers.ValueObjects.ContactNumber", "MobileNumber", b2 =>
{
b2.Property<int>("ContactInfoCustomerId")
.HasColumnType("int");
b2.Property<int>("ContactInfoId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b2.Property<int>("Number")
.HasColumnType("int");
b2.HasKey("ContactInfoCustomerId", "ContactInfoId");
b2.ToTable("ContactInfo");
b2.WithOwner()
.HasForeignKey("ContactInfoCustomerId", "ContactInfoId");
});
b1.OwnsOne("PSManagement.Domain.Customers.ValueObjects.ContactNumber", "PhoneNumber", b2 =>
{
b2.Property<int>("ContactInfoCustomerId")
.HasColumnType("int");
b2.Property<int>("ContactInfoId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b2.Property<int>("Number")
.HasColumnType("int");
b2.HasKey("ContactInfoCustomerId", "ContactInfoId");
b2.ToTable("ContactInfo");
b2.WithOwner()
.HasForeignKey("ContactInfoCustomerId", "ContactInfoId");
});
b1.Navigation("MobileNumber");
b1.Navigation("PhoneNumber");
});
b.OwnsOne("PSManagement.Domain.Customers.ValueObjects.Address", "Address", b1 =>
{
b1.Property<int>("CustomerId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("City")
.HasColumnType("nvarchar(max)");
b1.Property<string>("StreetName")
.HasColumnType("nvarchar(max)");
b1.Property<int>("StreetNumber")
.HasColumnType("int");
b1.Property<int>("ZipCode")
.HasColumnType("int");
b1.HasKey("CustomerId");
b1.ToTable("Customers");
b1.WithOwner()
.HasForeignKey("CustomerId");
});
b.Navigation("Address");
b.Navigation("ContactInfo");
});
#pragma warning restore 612, 618
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="EntitiesConfiguration\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.17">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.17" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.17">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.2" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PSManagement.Domain\PSManagement.Domain.csproj" />
<ProjectReference Include="..\PSManagement.SharedKernel\PSManagement.SharedKernel.csproj" />
</ItemGroup>
</Project>
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using PSManagement.SharedKernel.Entities;
using PSManagement.SharedKernel.Interfaces;
using PSManagement.SharedKernel.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PSManagement.Infrastructure.Persistence.Repositories.Base
{
public class BaseRepository<T> : IRepository<T> where T :BaseEntity
{
protected AppDbContext _dbContext;
internal DbSet<T> dbSet;
public BaseRepository(AppDbContext context)
{
_dbContext = context;
dbSet = context.Set<T>();
}
public async Task<T> AddAsync(T entity)
{
EntityEntry<T> entry = await dbSet.AddAsync(entity);
await _dbContext.SaveChangesAsync();
return entry.Entity;
}
public async Task<IEnumerable<T>> ListAsync()
{
return await dbSet.ToListAsync();
}
public async Task<IEnumerable<T>> ListAsync(ISpecification<T> specification)
{
var q = ApplySpecification(specification);
return await q.ToListAsync<T>();
}
public Task DeleteAsync(T entity)
{
_dbContext.Set<T>().Remove(entity);
return _dbContext.SaveChangesAsync();
}
public async Task<T> GetByIdAsync(int id, ISpecification<T> specification=null)
{
var q = ApplySpecification(specification);
return await q.SingleOrDefaultAsync(e => e.Id == id);
}
public async Task<T> UpdateAsync(T entity)
{
_dbContext.Entry(entity).State = EntityState.Modified;
await _dbContext.SaveChangesAsync();
return entity;
}
protected IQueryable<T> ApplySpecification(ISpecification<T> specification)
{
return SpecificationEvaluator<T>.GetQuery(dbSet.AsQueryable(), specification);
}
}
}
using PSManagement.SharedKernel.Entities;
using PSManagement.SharedKernel.Interfaces;
using Microsoft.EntityFrameworkCore;
using System.Linq;
namespace PSManagement.Infrastructure.Persistence.Repositories.Base
{
public class SpecificationEvaluator<T> where T : BaseEntity
{
public static IQueryable<T> GetQuery(IQueryable<T> inputQuery, ISpecification<T> specification)
{
var query = inputQuery;
if (specification is not null)
{
// modify the IQueryable using the specification's criteria expression
if (specification.Criteria != null)
{
query = query.Where(specification.Criteria);
}
// Includes all expression-based includes
query = specification.Includes.Aggregate(
query,
(current, include) => current.Include(include));
// Include any string-based include statements
query = specification.IncludeStrings.Aggregate(
query,
(current, include) => current.Include(include));
// Apply ordering if expressions are set
if (specification.OrderBy != null)
{
query = query.OrderBy(specification.OrderBy);
}
else if (specification.OrderByDescending != null)
{
query = query.OrderByDescending(specification.OrderByDescending);
}
//if (specification.GroupBy is not null)
//{
// query = query.GroupBy(specification.GroupBy).SelectMany(x => x);
//}
// Apply paging if enabled
if (specification.IsPagingEnabled)
{
query = query.Skip(specification.Skip)
.Take(specification.Take);
}
}
return query;
}
}
}
using PSManagement.Domain.Customers.Aggregate;
using PSManagement.Domain.Customers.Repositories;
using PSManagement.Infrastructure.Persistence.Repositories.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PSManagement.Infrastructure.Persistence.Repositories.CustomerRepository
{
public class CustomersReposiotry : BaseRepository<Customer> , ICustomersRepository
{
public CustomersReposiotry(AppDbContext context) : base(context)
{
}
}
}
using Microsoft.EntityFrameworkCore;
using PSManagement.Domain.Identity.Aggregate;
using PSManagement.Domain.Identity.Repositories;
using PSManagement.Infrastructure.Persistence.Repositories.Base;
using PSManagement.SharedKernel.Interfaces;
using PSManagement.SharedKernel.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PSManagement.Infrastructure.Persistence.Repositories.UserRepository
{
public class UsersRepository : BaseRepository<User> ,IUsersRepository
{
public UsersRepository(AppDbContext context) : base(context)
{
}
public static List<User> Users { get; set; } = new List<User>();
public async Task<User> GetByEmail(string email,ISpecification<User> specification = null)
{
return await ApplySpecification(specification).Where(u => u.Email == email).FirstOrDefaultAsync();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment