Book query tracking

This commit is contained in:
Paul Schneider 2017-01-20 14:19:23 +01:00
commit 32ca008d20
8 changed files with 1514 additions and 21 deletions

View file

@ -33,12 +33,16 @@ namespace Yavsc.Models
// For example, you can rename the ASP.NET Identity table names and more.
// Add your customizations after calling base.OnModelCreating(builder);
builder.Entity<Contact>().HasKey(x => new { x.OwnerId, x.UserId });
builder.Entity<BookQuery>().Property(x=>x.CreationDate).HasDefaultValueSql("LOCALTIMESTAMP");
builder.Entity<GoogleCloudMobileDeclaration>().Property(x=>x.DeclarationDate).HasDefaultValueSql("LOCALTIMESTAMP");
builder.Entity<PostTag>().HasKey(x=>new { x.PostId, x.TagId});
builder.Entity<ApplicationUser>().HasMany<Connection>( c=>c.Connections );
builder.Entity<UserActivity>().HasKey(u=> new { u.DoesCode, u.UserId});
builder.Entity<Instrumentation>().HasKey(u=> new { u.InstrumentId, u.UserId});
builder.Entity<CircleAuthorizationToBlogPost>().HasKey(a=> new { a.CircleId, a.BlogPostId});
foreach (var et in builder.Model.GetEntityTypes()) {
if (et.ClrType.GetInterface("IBaseTrackedEntity")!=null)
et.FindProperty("DateCreated").IsReadOnlyAfterSave = true;
}
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
@ -224,11 +228,11 @@ namespace Yavsc.Models
{
if (entity.State == EntityState.Added)
{
((IBaseTrackedEntity)entity.Entity).DateCreated = DateTime.UtcNow;
((IBaseTrackedEntity)entity.Entity).DateCreated = DateTime.Now;
((IBaseTrackedEntity)entity.Entity).UserCreated = currentUsername;
}
((IBaseTrackedEntity)entity.Entity).DateModified = DateTime.UtcNow;
((IBaseTrackedEntity)entity.Entity).DateModified = DateTime.Now;
((IBaseTrackedEntity)entity.Entity).UserModified = currentUsername;
}
}
@ -245,5 +249,8 @@ namespace Yavsc.Models
}
public DbSet<Circle> Circle { get; set; }
public DbSet<CircleAuthorizationToBlogPost> BlogACL { get; set; }
}
}

View file

@ -8,7 +8,7 @@ using Yavsc.Models.Workflow;
namespace Yavsc.Models.Billing
{
public class NominativeServiceCommand<T> : Query<T> where T:Service
public class NominativeServiceCommand<T> : Query<T> where T:Service
{
public string ClientId { get; set; }
@ -29,11 +29,7 @@ namespace Yavsc.Models.Billing
public DateTime? ValidationDate {get; set;}
/// <summary>
/// Command creation Date & time
/// </summary>
/// <returns></returns>
public DateTime CreationDate {get; set;}
public decimal? Previsional { get; set; }
/// <summary>

View file

@ -1,11 +1,32 @@
using System;
using Yavsc.Interfaces.Workflow;
using Yavsc.Models.Market;
namespace Yavsc.Models.Billing
{
public class Query<P> where P : BaseProduct
public class Query<P>: IBaseTrackedEntity where P : BaseProduct
{
public DateTime DateCreated
{
get; set;
}
public DateTime DateModified
{
get; set;
}
public string UserCreated
{
get; set;
}
public string UserModified
{
get; set;
}
QueryStatus Status { get; set; }
}

View file

@ -11,7 +11,7 @@ namespace Yavsc.Models.Booking
/// Query, for a date, with a given perfomer, at this given place.
/// </summary>
public class BookQuery : NominativeServiceCommand<RendezVous>
public class BookQuery : NominativeServiceCommand<RendezVous>, IBaseTrackedEntity
{
/// <summary>
/// The command identifier