refacto query status
This commit is contained in:
parent
ee6cb34c23
commit
7b3a236bcc
11 changed files with 20 additions and 53 deletions
|
|
@ -41,7 +41,7 @@ namespace Yavsc.Helpers
|
|||
}
|
||||
|
||||
public static void RegisterBilling<T>(string code, Func<ApplicationDbContext, long,
|
||||
IDecidableQuery> getter) where T : IBillable
|
||||
IQuery> getter) where T : IBillable
|
||||
{
|
||||
lock (_billingLock)
|
||||
{
|
||||
|
|
@ -91,7 +91,7 @@ namespace Yavsc.Helpers
|
|||
}
|
||||
}
|
||||
|
||||
RegisterBilling<HairCutQuery>(BillingCodes.Brush, new Func<ApplicationDbContext, long, IDecidableQuery>
|
||||
RegisterBilling<HairCutQuery>(BillingCodes.Brush, new Func<ApplicationDbContext, long, IQuery>
|
||||
((db, id) =>
|
||||
{
|
||||
var query = db.HairCutQueries.Include(q => q.Prestation).Include(q => q.Regularisation).Single(q => q.Id == id);
|
||||
|
|
@ -99,10 +99,10 @@ namespace Yavsc.Helpers
|
|||
return query;
|
||||
}));
|
||||
|
||||
RegisterBilling<HairMultiCutQuery>(BillingCodes.MBrush, new Func<ApplicationDbContext, long, IDecidableQuery>
|
||||
RegisterBilling<HairMultiCutQuery>(BillingCodes.MBrush, new Func<ApplicationDbContext, long, IQuery>
|
||||
((db, id) => db.HairMultiCutQueries.Include(q => q.Regularisation).Single(q => q.Id == id)));
|
||||
|
||||
RegisterBilling<RdvQuery>(BillingCodes.Rdv, new Func<ApplicationDbContext, long, IDecidableQuery>
|
||||
RegisterBilling<RdvQuery>(BillingCodes.Rdv, new Func<ApplicationDbContext, long, IQuery>
|
||||
((db, id) => db.RdvQueries.Include(q => q.Regularisation).Single(q => q.Id == id)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Yavsc.Models.Billing
|
|||
using Yavsc.Abstract.Workflow;
|
||||
using Yavsc.Services;
|
||||
|
||||
public abstract class NominativeServiceCommand : IDecidableQuery, IIdentified<long>, IBillable
|
||||
public abstract class NominativeServiceCommand : IQuery, IIdentified<long>, IBillable
|
||||
{
|
||||
public string GetInvoiceId() { return GetType().Name + "/" + Id; }
|
||||
|
||||
|
|
@ -78,9 +78,6 @@ namespace Yavsc.Models.Billing
|
|||
[ForeignKey("ActivityCode"),JsonIgnore,Display(Name="Domaine d'activité")]
|
||||
public virtual Activity Context { get; set ; }
|
||||
|
||||
public bool Reviewed { get; set; }
|
||||
|
||||
|
||||
public abstract System.Collections.Generic.List<IBillItem> GetBillItems();
|
||||
|
||||
public bool GetIsAcquitted()
|
||||
|
|
@ -102,6 +99,5 @@ namespace Yavsc.Models.Billing
|
|||
|
||||
[Display(Name = "Acquittement de la facture")]
|
||||
public virtual PayPalPayment Regularisation { get; set; }
|
||||
public bool Accepted { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ namespace Yavsc.Services
|
|||
public class BillingService : IBillingService
|
||||
{
|
||||
public ApplicationDbContext DbContext { get; private set; }
|
||||
public static Dictionary<string, Func<ApplicationDbContext, long, IDecidableQuery>> Billing =
|
||||
new Dictionary<string, Func<ApplicationDbContext, long, IDecidableQuery>>();
|
||||
public static Dictionary<string, Func<ApplicationDbContext, long, IQuery>> Billing =
|
||||
new Dictionary<string, Func<ApplicationDbContext, long, IQuery>>();
|
||||
public static List<PropertyInfo> UserSettings = new List<PropertyInfo>();
|
||||
|
||||
public static Dictionary<string, string> GlobalBillingMap =
|
||||
|
|
@ -25,12 +25,12 @@ namespace Yavsc.Services
|
|||
DbContext = dbContext;
|
||||
}
|
||||
|
||||
public Task<IDecidableQuery> GetBillAsync(string billingCode, long queryId)
|
||||
public Task<IQuery> GetBillAsync(string billingCode, long queryId)
|
||||
{
|
||||
return Task.FromResult(GetBillable(DbContext, billingCode, queryId));
|
||||
}
|
||||
|
||||
public static IDecidableQuery GetBillable(ApplicationDbContext context, string billingCode, long queryId) => Billing[billingCode](context, queryId);
|
||||
public static IQuery GetBillable(ApplicationDbContext context, string billingCode, long queryId) => Billing[billingCode](context, queryId);
|
||||
public async Task<IUserSettings> GetPerformersSettingsAsync(string activityCode, string userId)
|
||||
{
|
||||
var activity = await DbContext.Activities.SingleAsync(a => a.Code == activityCode);
|
||||
|
|
@ -39,7 +39,7 @@ namespace Yavsc.Services
|
|||
|
||||
var dbSetGetter =
|
||||
UserSettings.SingleOrDefault(s => s.Name == activity.SettingsClassName);
|
||||
|
||||
|
||||
if (dbSetGetter==null) return null;
|
||||
var dbSet = dbSetGetter.GetValue(DbContext);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue