yavsc/Yavsc/Helpers/EventHelpers.cs

96 lines
3.2 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;
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,
Message = string.Format(SR["RdvToPerf"],
query.Client.UserName,
query.EventDate.ToString("dddd dd/MM/yyyy à HH:mm"),
query.Location.Address,
query.ActivityCode)+
"\n"+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,
2017-01-16 15:34:05 +01:00
ActivityCode = query.ActivityCode
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",
string.Format(Startup.GlobalLocalizer["HairCutQueryValidation"],query.Client.UserName),
$"{query.Client.UserName}",
2017-05-30 23:39:56 +02:00
$@"Un client vient de valider une demande de prestation à votre encontre:
Prestation: {strprestation}
Client : {query.Client.UserName}
Date: {evdate},
Adresse: {address}
2017-04-08 09:17:15 +02:00
-----
2017-05-30 23:39:56 +02:00
{query.AdditionalInfo}
Facture prévue (non réglée):
2017-04-08 09:17:15 +02:00
2017-06-02 21:34:18 +02:00
{query.GetBillText()}
") ;
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,
Message = string.Format(SR["RdvToPerf"],
query.Client.UserName,
query.EventDate.ToString("dddd dd/MM/yyyy à HH:mm"),
query.Location.Address,
query.ActivityCode),
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
};
return yaev;
}
2016-05-17 18:22:18 +02:00
}
}