public class UserEntityConfiguration : IEntityTypeConfiguration<UserEntity>
{
public void Configure(EntityTypeBuilder<UserEntity> builder)
{
builder.UseTpcMappingStrategy();
builder.HasKey(x => x.Id).HasName("id");
builder.Property(x => x.Name).HasMaxLength(25).IsRequired().HasColumnName("name");
builder.Property(x => x.Email).HasMaxLength(50).IsRequired().HasColumnName("email");
builder.Property(x => x.EmailVerify).IsRequired().HasColumnName("email_verify");
builder.Property(x => x.PasswordHash).IsRequired().HasColumnName("password_hash");
}
}
public class SellerEntityConfiguration : IEntityTypeConfiguration<SellerEntity>
{
public void Configure(EntityTypeBuilder<SellerEntity> builder)
{
builder.UseTpcMappingStrategy();
builder.ToTable("sellers");
builder.Property(x => x.Description).IsRequired().HasMaxLength(500).HasColumnName("description");
builder.HasMany(x => x.Products).WithOne().HasConstraintName("products_constraint");
}
}
public class CustomerEntityConfiguration : IEntityTypeConfiguration<CustomerEntity>
{
public void Configure(EntityTypeBuilder<CustomerEntity> builder)
{
builder.UseTpcMappingStrategy();
builder.ToTable("customers");
builder.Property(x => x.CreditCard).IsRequired().HasMaxLength(35).HasColumnName("credit_card");
builder.HasMany(x => x.Purchases)
.WithOne().HasConstraintName("purchases_constraint");
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new UserEntityConfiguration());
modelBuilder.ApplyConfiguration(new RefreshTokenEntityConfigurations());
modelBuilder.ApplyConfiguration(new CustomerEntityConfiguration());
modelBuilder.ApplyConfiguration(new SellerEntityConfiguration());
modelBuilder.ApplyConfiguration(new ProductEntityCongurations());
}
public class SellerLoginController : BaseLoginController
{
public SellerLoginController(SellerService sellerService, IServiceProvider provider) : base(provider)
{
_sellerService = sellerService;
}
private readonly SellerService _sellerService;
protected override IUserService<UserEntity> _userService { get => _sellerService; }
//Место где и возникает проблема(Cannot implicitly convert type 'SellerService' to 'IUserService'. An explicit conversion exists (are you missing a cast?)
public abstract class BaseLoginController : ControllerBase
{
protected abstract IUserService<UserEntity> _userService { get; }
...
}
[ApiController]
[Route("/api/notes")]
[ValidationFilter]
[Authorize]
public class NoteController : ControllerBase
{
private readonly ILogger<NoteController> _logger;
private readonly string _authorId;
public NoteController(ILogger<NoteController> logger)
{
_logger = logger;
var id = User?.Claims?.GetIdValue();
_authorId = id is not null ? id : default;
_logger.LogCritical("Author: \t n:");
_logger.LogCritical(_authorId);
}
...
}
public static class ClaimsExtension
{
private static string GetValue(Claim[] claims, string selectType) => claims.FirstOrDefault(c => c.Type == selectType).Value;
private static string GetValue(IEnumerable<Claim> claims, string selectType) => claims.FirstOrDefault(c => c.Type == selectType).Value;
public static string GetIdValue(this Claim[] claims) => GetValue(claims, "userId");
public static string GetIdValue(this IEnumerable<Claim> claims) => GetValue(claims, "userId");
}
public class FaviconMiddleware
{
private const string PATHTOFAVICON = "/home/timur/Desktop/FullStackProj1/serverApp/favicon.jpg";
private readonly RequestDelegate _next;
public FaviconMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext context)
{
if (context.Request.Path.Value == "/favicon.ico")
{
await context.Response.SendFileAsync(PATHTOFAVICON);
return;
}
await _next(context);
}
}
и все ровно получаю все тот же 400 код. Не знаете в чем может быть дело? (Миддлвеер в Program вызываю)