yavsc/Yavsc/Helpers/EventHelpers.cs

77 lines
2.7 KiB
C#
Raw Normal View History

2016-05-17 18:22:18 +02:00
using Microsoft.Extensions.Localization;
namespace Yavsc.Helpers
{
2017-02-11 15:46:26 +01:00
using Models.Workflow;
using Models.Messaging;
2017-02-27 19:28:32 +01:00
using Yavsc.Models.Haircut;
2017-06-02 21:34:18 +02:00
using Yavsc.Models;
2018-02-25 03:33:54 +01:00
using Yavsc.Models.Billing;
2017-02-27 19:28:32 +01:00
2016-05-17 18:22:18 +02:00
public static class EventHelpers
{
2017-02-27 19:28:32 +01:00
public static RdvQueryEvent CreateEvent(this RdvQuery query,
2017-06-02 21:34:18 +02:00
IStringLocalizer SR, string subtopic)
2016-05-17 18:22:18 +02:00
{
2017-06-02 21:34:18 +02:00
var yaev = new RdvQueryEvent(subtopic)
2017-04-01 02:14:10 +02:00
{
2017-02-27 19:28:32 +01:00
Sender = query.ClientId,
2018-02-03 20:17:29 +01:00
Reason = query.Reason,
Client = new ClientProviderInfo { 
2017-04-01 02:14:10 +02:00
UserName = query.Client.UserName ,
UserId = query.ClientId,
Avatar = query.Client.Avatar } ,
2016-09-17 03:36:34 +02:00
Previsional = query.Previsional,
EventDate = query.EventDate,
Location = query.Location,
Id = query.Id,
ActivityCode = query.ActivityCode,
2018-02-25 03:33:54 +01:00
BillingCode = BillingCodes.Rdv
2016-05-17 18:22:18 +02:00
};
2017-06-02 21:34:18 +02:00
2016-05-17 18:22:18 +02:00
return yaev;
}
2017-05-30 23:39:56 +02:00
2017-06-02 21:34:18 +02:00
public static HairCutQueryEvent CreateNewHairCutQueryEvent(this HairCutQuery query,
IStringLocalizer SR)
{
string evdate = query.EventDate?.ToString("dddd dd/MM/yyyy à hh:mm")??"[pas de date spécifiée]";
2017-04-08 09:17:15 +02:00
string address = query.Location?.Address??"[pas de lieu spécifié]";
var p = query.Prestation;
2017-05-30 23:39:56 +02:00
string strprestation = query.GetDescription();
2017-06-02 21:34:18 +02:00
var yaev = query.CreateEvent("NewHairCutQuery",
2018-03-26 23:18:48 +02:00
string.Format(ResourcesHelpers.GlobalLocalizer["HairCutQueryValidation"],query.Client.UserName),
2018-02-25 03:33:54 +01:00
$"{query.Client.Id}");
2017-05-28 06:14:36 +02:00
2017-02-27 19:28:32 +01:00
return yaev;
}
2017-06-02 21:34:18 +02:00
public static string GetSender(this ApplicationUser user)
{
return user.UserName+" ["+user.Id+"@"+Startup.Authority+"]";
}
2017-02-27 19:28:32 +01:00
public static HairCutQueryEvent CreateEvent(this HairMultiCutQuery query,
2017-04-08 09:17:15 +02:00
IStringLocalizer SR, BrusherProfile bpr)
2017-02-27 19:28:32 +01:00
{
2017-06-02 21:34:18 +02:00
var yaev = new HairCutQueryEvent("newCommand")
2017-04-01 02:14:10 +02:00
{
2017-02-27 19:28:32 +01:00
Sender = query.ClientId,
2018-02-03 20:17:29 +01:00
2017-02-27 19:28:32 +01:00
Client = new ClientProviderInfo { 
2017-04-01 02:14:10 +02:00
UserName = query.Client.UserName ,
UserId = query.ClientId,
2017-02-27 19:28:32 +01:00
Avatar = query.Client.Avatar } ,
Previsional = query.Previsional,
EventDate = query.EventDate,
Location = query.Location,
Id = query.Id,
Reason = "Commande groupée!",
ActivityCode = query.ActivityCode,
2018-02-25 03:33:54 +01:00
BillingCode = BillingCodes.MBrush
2017-02-27 19:28:32 +01:00
};
return yaev;
}
2016-05-17 18:22:18 +02:00
}
}