yavsc/Yavsc/Helpers/EventHelpers.cs

98 lines
3.3 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;
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,
2016-05-17 18:22:18 +02:00
IStringLocalizer SR)
{
2017-02-27 19:28:32 +01:00
var yaev = new RdvQueryEvent
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
Reason = query.Reason,
ActivityCode = query.ActivityCode
2016-05-17 18:22:18 +02:00
};
return yaev;
}
2017-02-27 19:28:32 +01:00
public static HairCutQueryEvent CreateEvent(this HairCutQuery query,
2017-04-08 09:17:15 +02:00
IStringLocalizer SR, BrusherProfile bpr)
2017-02-27 19:28:32 +01:00
{
2017-04-08 09:17:15 +02:00
string head = SR["HaircutRdvQuery"];
string evdate = query.EventDate?.ToString("dddd dd/MM/yyyy à HH:mm")??"[pas de date spécifiée]";
string address = query.Location?.Address??"[pas de lieu spécifié]";
var p = query.Prestation;
decimal total = query.Prestation.Addition(bpr);
string strprestation = $@"Coupe: {p.Cut}, Total: {total}";
2017-02-27 19:28:32 +01:00
var yaev = new HairCutQueryEvent
2017-04-01 02:14:10 +02:00
{
2017-02-27 19:28:32 +01:00
Sender = query.ClientId,
2017-04-08 09:17:15 +02:00
Message = $@"{head}: {query.Client.UserName},
{evdate},
{address}
-----
{strprestation}
--
{query.AdditionalInfo}
" ,
Client = new ClientProviderInfo { 
UserName = query.Client.UserName ,
UserId = query.ClientId,
Avatar = query.Client.Avatar } ,
Previsional = query.Previsional,
EventDate = query.EventDate,
Location = query.Location,
Id = query.Id,
Reason = query.AdditionalInfo,
ActivityCode = query.ActivityCode
2017-02-27 19:28:32 +01:00
};
return yaev;
}
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
{
var yaev = new HairCutQueryEvent
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
}
}