Complete some TODOs.

pull/81/head
Halil İbrahim Kalkan 9 years ago
parent 4960d3a247
commit 1254b53628

@ -25,7 +25,7 @@ namespace AbpDesk.Tickets
public async Task<ListResultDto<TicketDto>> GetAll(GetAllTicketsInput input)
{
//TODO: Use conventional unit of work for application services when it's available!
//Use conventional unit of work for application services when it's available!
using (var unitOfWork = _unitOfWorkManager.Begin())
{
var tickets = _ticketRepository

@ -9,19 +9,29 @@ namespace AbpDesk.ConsoleDemo
public class Program
{
public static void Main(string[] args)
{
try
{
RunDemo();
}
catch (Exception ex)
{
Console.WriteLine("ERROR: " + ex.Message);
Console.ReadLine();
}
}
private static void RunDemo()
{
var services = new ServiceCollection();
var application = services.AddApplication<AbpDeskConsoleDemoModule>(options =>
{
AddPlugIns(options);
});
var application = services.AddApplication<AbpDeskConsoleDemoModule>(options => { AddPlugIns(options); });
using (var scope = services.BuildServiceProvider().CreateScope())
{
application.Initialize(scope.ServiceProvider);
RunDemo(application);
RunListers(application);
Console.WriteLine("Press ENTER to run again...");
Console.ReadLine();
@ -30,7 +40,7 @@ namespace AbpDesk.ConsoleDemo
}
}
private static void RunDemo(AbpApplication application)
private static void RunListers(AbpApplication application)
{
application
.ServiceProvider

@ -5,7 +5,7 @@ using Volo.Abp.Domain.Entities;
namespace AbpDesk.Tickets
{
public class Ticket : AggregateRoot<int>
public class Ticket : AggregateRoot<int>, IHasConcurrencyStamp
{
public const int MaxTitleLength = 256;
@ -18,6 +18,8 @@ namespace AbpDesk.Tickets
[MaxLength(MaxBodyLength)]
public string Body { get; set; }
public string ConcurrencyStamp { get; set; }
protected Ticket()
{

@ -23,6 +23,7 @@ namespace AbpDesk.EntityFrameworkCore
modelBuilder.Entity<Ticket>(builder =>
{
builder.ToTable("DskTickets");
builder.Property(t => t.ConcurrencyStamp).IsConcurrencyToken();
});
}
}

@ -0,0 +1,40 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using AbpDesk.EntityFrameworkCore;
namespace AbpDesk.EntityFrameworkCore.Migrations
{
[DbContext(typeof(AbpDeskDbContext))]
[Migration("20170123062008_Added_ConcurrencyStamp_To_Ticket")]
partial class Added_ConcurrencyStamp_To_Ticket
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
modelBuilder
.HasAnnotation("ProductVersion", "1.1.0-rtm-22752")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("AbpDesk.Tickets.Ticket", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Body")
.HasMaxLength(65536);
b.Property<string>("ConcurrencyStamp");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(256);
b.HasKey("Id");
b.ToTable("DskTickets");
});
}
}
}

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
namespace AbpDesk.EntityFrameworkCore.Migrations
{
public partial class Added_ConcurrencyStamp_To_Ticket : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ConcurrencyStamp",
table: "DskTickets",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ConcurrencyStamp",
table: "DskTickets");
}
}
}

@ -24,6 +24,8 @@ namespace AbpDesk.EntityFrameworkCore.Migrations
b.Property<string>("Body")
.HasMaxLength(65536);
b.Property<string>("ConcurrencyStamp");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(256);

@ -93,7 +93,7 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
if (entity is IHasConcurrencyStamp)
{
(entity as IHasConcurrencyStamp).ConcurrencyStamp = Guid.NewGuid().ToString(); //TODO: Use IGuidGenerator!
(entity as IHasConcurrencyStamp).ConcurrencyStamp = Guid.NewGuid().ToString();
}
return DbContext.Update(entity).Entity;

@ -14,6 +14,13 @@ namespace Volo.Abp.EntityFrameworkCore
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
//TODO: Automatically configure ConcurrencyStamp
}
public override int SaveChanges(bool acceptAllChangesOnSuccess)
{
try
@ -22,7 +29,6 @@ namespace Volo.Abp.EntityFrameworkCore
}
catch (DbUpdateConcurrencyException ex)
{
//TODO: Better exception message using DbUpdateConcurrencyException
throw new AbpDbConcurrencyException(ex.Message, ex);
}
}
@ -35,7 +41,6 @@ namespace Volo.Abp.EntityFrameworkCore
}
catch (DbUpdateConcurrencyException ex)
{
//TODO: Better exception message using DbUpdateConcurrencyException
throw new AbpDbConcurrencyException(ex.Message, ex);
}
}

@ -33,7 +33,7 @@ namespace Volo.Abp.EntityFrameworkCore.DependencyInjection
}
else
{
throw new AbpException("Should set a configure action for dbcontext"); //TODO: Better message
throw new AbpException($"No configuration found for {typeof(DbContext).AssemblyQualifiedName}! Use services.Configure<AbpDbContextOptions>(...) to configure it.");
}
return context.DbContextOptions.Options;

@ -0,0 +1,231 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Volo.Abp.Identity.EntityFrameworkCore;
namespace Volo.Abp.Identity.EntityFrameworkCore.Migrations
{
[DbContext(typeof(IdentityDbContext))]
[Migration("20170123063841_Remove_Unique_Index_Constraints")]
partial class Remove_Unique_Index_Constraints
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
modelBuilder
.HasAnnotation("ProductVersion", "1.1.0-rtm-22752")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.HasName("RoleNameIndex");
b.ToTable("IdentityRoles");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<Guid>("RoleId");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("IdentityRoleClaims");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.HasName("UserNameIndex");
b.ToTable("IdentityUsers");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<Guid>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("IdentityUserClaims");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("LoginProvider");
b.Property<string>("ProviderDisplayName");
b.Property<string>("ProviderKey");
b.Property<Guid>("UserId");
b.HasKey("Id");
b.HasIndex("UserId", "LoginProvider", "ProviderKey");
b.ToTable("IdentityUserLogins");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<Guid>("RoleId");
b.Property<Guid>("UserId");
b.HasKey("Id");
b.HasIndex("RoleId");
b.HasIndex("UserId", "RoleId");
b.ToTable("IdentityUserRoles");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<Guid>("UserId");
b.Property<string>("Value");
b.HasKey("Id");
b.HasIndex("UserId", "LoginProvider", "Name");
b.ToTable("IdentityUserTokens");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityRole")
.WithMany("Claims")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityUser")
.WithMany("Claims")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityUser")
.WithMany("Logins")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Volo.Abp.Identity.IdentityUser")
.WithMany("Roles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityUser")
.WithMany("Tokens")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
}
}
}

@ -0,0 +1,110 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.Abp.Identity.EntityFrameworkCore.Migrations
{
public partial class Remove_Unique_Index_Constraints : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_IdentityUserTokens_UserId_LoginProvider_Name",
table: "IdentityUserTokens");
migrationBuilder.DropIndex(
name: "IX_IdentityUserRoles_UserId_RoleId",
table: "IdentityUserRoles");
migrationBuilder.DropIndex(
name: "IX_IdentityUserLogins_UserId_LoginProvider_ProviderKey",
table: "IdentityUserLogins");
migrationBuilder.DropIndex(
name: "UserNameIndex",
table: "IdentityUsers");
migrationBuilder.DropIndex(
name: "RoleNameIndex",
table: "IdentityRoles");
migrationBuilder.CreateIndex(
name: "IX_IdentityUserTokens_UserId_LoginProvider_Name",
table: "IdentityUserTokens",
columns: new[] { "UserId", "LoginProvider", "Name" });
migrationBuilder.CreateIndex(
name: "IX_IdentityUserRoles_UserId_RoleId",
table: "IdentityUserRoles",
columns: new[] { "UserId", "RoleId" });
migrationBuilder.CreateIndex(
name: "IX_IdentityUserLogins_UserId_LoginProvider_ProviderKey",
table: "IdentityUserLogins",
columns: new[] { "UserId", "LoginProvider", "ProviderKey" });
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "IdentityUsers",
column: "NormalizedUserName");
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "IdentityRoles",
column: "NormalizedName");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_IdentityUserTokens_UserId_LoginProvider_Name",
table: "IdentityUserTokens");
migrationBuilder.DropIndex(
name: "IX_IdentityUserRoles_UserId_RoleId",
table: "IdentityUserRoles");
migrationBuilder.DropIndex(
name: "IX_IdentityUserLogins_UserId_LoginProvider_ProviderKey",
table: "IdentityUserLogins");
migrationBuilder.DropIndex(
name: "UserNameIndex",
table: "IdentityUsers");
migrationBuilder.DropIndex(
name: "RoleNameIndex",
table: "IdentityRoles");
migrationBuilder.CreateIndex(
name: "IX_IdentityUserTokens_UserId_LoginProvider_Name",
table: "IdentityUserTokens",
columns: new[] { "UserId", "LoginProvider", "Name" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_IdentityUserRoles_UserId_RoleId",
table: "IdentityUserRoles",
columns: new[] { "UserId", "RoleId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_IdentityUserLogins_UserId_LoginProvider_ProviderKey",
table: "IdentityUserLogins",
columns: new[] { "UserId", "LoginProvider", "ProviderKey" },
unique: true);
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "IdentityUsers",
column: "NormalizedUserName",
unique: true);
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "IdentityRoles",
column: "NormalizedName",
unique: true);
}
}
}

@ -33,7 +33,6 @@ namespace Volo.Abp.Identity.EntityFrameworkCore.Migrations
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("IdentityRoles");
@ -101,7 +100,6 @@ namespace Volo.Abp.Identity.EntityFrameworkCore.Migrations
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("IdentityUsers");
@ -140,8 +138,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore.Migrations
b.HasKey("Id");
b.HasIndex("UserId", "LoginProvider", "ProviderKey")
.IsUnique();
b.HasIndex("UserId", "LoginProvider", "ProviderKey");
b.ToTable("IdentityUserLogins");
});
@ -159,8 +156,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore.Migrations
b.HasIndex("RoleId");
b.HasIndex("UserId", "RoleId")
.IsUnique();
b.HasIndex("UserId", "RoleId");
b.ToTable("IdentityUserRoles");
});
@ -180,8 +176,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore.Migrations
b.HasKey("Id");
b.HasIndex("UserId", "LoginProvider", "Name")
.IsUnique();
b.HasIndex("UserId", "LoginProvider", "Name");
b.ToTable("IdentityUserTokens");
});

@ -61,15 +61,17 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
/// </param>
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
//TODO: Set Default Values for properties
//TODO: Unique indexes can be a problem for a multi-tenant application. Think again.
//TODO: Split configuration to dedicated classes.
builder.Entity<IdentityUser>(b =>
{
b.ToTable("IdentityUsers");
b.Property(u => u.ConcurrencyStamp).IsConcurrencyToken(); //TODO: Do automatically?
b.Property(u => u.ConcurrencyStamp).IsConcurrencyToken();
b.Property(u => u.UserName).HasMaxLength(256);
b.Property(u => u.NormalizedUserName).HasMaxLength(256);
b.Property(u => u.Email).HasMaxLength(256);
@ -80,7 +82,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
b.HasMany(u => u.Roles).WithOne().HasForeignKey(ur => ur.UserId).IsRequired();
b.HasMany(u => u.Tokens).WithOne().HasForeignKey(ur => ur.UserId).IsRequired();
b.HasIndex(u => u.NormalizedUserName).HasName("UserNameIndex").IsUnique();
b.HasIndex(u => u.NormalizedUserName).HasName("UserNameIndex");
b.HasIndex(u => u.NormalizedEmail).HasName("EmailIndex");
});
@ -96,7 +98,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
//b.HasMany(r => r.Users).WithOne().HasForeignKey(ur => ur.RoleId).IsRequired();
b.HasMany(r => r.Claims).WithOne().HasForeignKey(rc => rc.RoleId).IsRequired();
b.HasIndex(r => r.NormalizedName).HasName("RoleNameIndex").IsUnique();
b.HasIndex(r => r.NormalizedName).HasName("RoleNameIndex");
});
builder.Entity<IdentityUserClaim>(b =>
@ -115,21 +117,21 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
b.HasOne<IdentityRole>().WithMany().HasForeignKey(ur => ur.RoleId).IsRequired();
b.HasIndex(r => new { r.UserId, r.RoleId }).IsUnique();
b.HasIndex(r => new { r.UserId, r.RoleId });
});
builder.Entity<IdentityUserLogin>(b =>
{
b.ToTable("IdentityUserLogins");
b.HasIndex(l => new { l.UserId, l.LoginProvider, l.ProviderKey }).IsUnique();
b.HasIndex(l => new { l.UserId, l.LoginProvider, l.ProviderKey });
});
builder.Entity<IdentityUserToken>(b =>
{
b.ToTable("IdentityUserTokens");
b.HasIndex(l => new { l.UserId, l.LoginProvider, l.Name }).IsUnique();
b.HasIndex(l => new { l.UserId, l.LoginProvider, l.Name });
});
}
}

@ -11,6 +11,8 @@ namespace Volo.Abp.Uow
[CanBeNull]
IDatabaseApi FindDatabaseApi([NotNull] string id);
//TODO: Move Database API methods to another interface!
[NotNull]
IDatabaseApi GetOrAddDatabaseApi(string id, Func<IDatabaseApi> factory);

Loading…
Cancel
Save