yavsc/Yavsc/Helpers/EventHelpers.cs

111 lines
3.7 KiB
C#

using Microsoft.Extensions.Localization;
namespace Yavsc.Helpers
{
8 years ago
using Models.Workflow;
using Models.Messaging;
8 years ago
using Yavsc.Models.Haircut;
7 years ago
using System.Linq;
using System.Globalization;
8 years ago
public static class EventHelpers
{
8 years ago
public static RdvQueryEvent CreateEvent(this RdvQuery query,
IStringLocalizer SR)
{
8 years ago
var yaev = new RdvQueryEvent
{
8 years ago
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 { 
UserName = query.Client.UserName ,
UserId = query.ClientId,
Avatar = query.Client.Avatar } ,
Previsional = query.Previsional,
EventDate = query.EventDate,
Location = query.Location,
Id = query.Id,
8 years ago
Reason = query.Reason,
ActivityCode = query.ActivityCode
};
return yaev;
}
8 years ago
public static HairCutQueryEvent CreateEvent(this HairCutQuery query,
8 years ago
IStringLocalizer SR, BrusherProfile bpr)
8 years ago
{
7 years ago
8 years ago
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;
string total = query.GetBillItems().Addition().ToString("C",CultureInfo.CurrentUICulture);
7 years ago
string strprestation = query.GetDescription();
7 years ago
string bill = string.Join("\n", query.GetBillItems().Select(
7 years ago
l=> $"{l.Name} {l.Description} {l.UnitaryCost} € " +
((l.Count != 1) ? "*"+l.Count.ToString() : "")));
8 years ago
var yaev = new HairCutQueryEvent
{
7 years ago
Sender = $"{strprestation} pour {query.Client.UserName}",
Message =
$@"Un client vient de valider une demande de prestation à votre encontre:
Prestation: {strprestation}
Client : {query.Client.UserName}
Date: {evdate},
Adresse: {address}
8 years ago
-----
7 years ago
{query.AdditionalInfo}
Facture prévue (non réglée):
8 years ago
7 years ago
{bill}
7 years ago
Total: {total}
8 years ago
" ,
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,
7 years ago
Reason = $"{query.AdditionalInfo}",
8 years ago
ActivityCode = query.ActivityCode
8 years ago
};
return yaev;
}
public static HairCutQueryEvent CreateEvent(this HairMultiCutQuery query,
8 years ago
IStringLocalizer SR, BrusherProfile bpr)
8 years ago
{
var yaev = new HairCutQueryEvent
{
8 years ago
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 { 
UserName = query.Client.UserName ,
UserId = query.ClientId,
8 years ago
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;
}
}
}