refactoring messages
This commit is contained in:
@ -59,7 +59,6 @@ namespace Yavsc.Models.Billing
|
||||
set { AttachedFiles = value.Split(':').ToList(); }
|
||||
}
|
||||
|
||||
[Required]
|
||||
public string OwnerId { get; set; }
|
||||
|
||||
[ForeignKey("OwnerId"),JsonIgnore]
|
||||
|
@ -29,12 +29,17 @@ namespace Yavsc.Models.Calendar
|
||||
/// <summary>
|
||||
/// Provided event.
|
||||
/// </summary>
|
||||
public class ProvidedEvent : YaEvent {
|
||||
public class ProvidedEvent : BaseEvent {
|
||||
/// <summary>
|
||||
/// The privacy.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public Publishing Privacy;
|
||||
}
|
||||
|
||||
public override string CreateBody()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
76
Yavsc/Models/HairCut/HairCutPaymentEvent.cs
Normal file
76
Yavsc/Models/HairCut/HairCutPaymentEvent.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using System.Linq;
|
||||
|
||||
using Yavsc.Interfaces.Workflow;
|
||||
using Yavsc.Models.Haircut;
|
||||
using Yavsc.ViewModels.PayPal;
|
||||
using Yavsc.Helpers;
|
||||
|
||||
namespace Yavsc.Models.HairCut
|
||||
{
|
||||
public class HairCutPayementEvent: IEvent
|
||||
{
|
||||
public HairCutPayementEvent(string sender, PaymentInfo info, HairCutQuery query, IStringLocalizer localizer)
|
||||
{
|
||||
Sender = sender;
|
||||
this.query = query;
|
||||
invoiceId = info.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.InvoiceID;
|
||||
payerName = info.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.Name;
|
||||
phone = info.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.Phone;
|
||||
payerEmail = info.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Payer;
|
||||
amount = string.Join(", ",
|
||||
info.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.PaymentDetails.Select(
|
||||
p => $"{p.OrderTotal.value} {p.OrderTotal.currencyID}"));
|
||||
gender = query.Prestation.Gender;
|
||||
date = query.EventDate?.ToString("dd MM yyyy hh:mm");
|
||||
lieu = query.Location.Address;
|
||||
clientFinal = (gender == HairCutGenders.Women) ? localizer["Women"] +
|
||||
" " + localizer[query.Prestation.Length.ToString()] : localizer[gender.ToString()];
|
||||
token = info.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.Token;
|
||||
payerId = info.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerID;
|
||||
}
|
||||
|
||||
public string Topic => "/topic/HaircutPayment";
|
||||
|
||||
public string Sender { get; set; }
|
||||
|
||||
HairCutQuery query;
|
||||
|
||||
private string invoiceId;
|
||||
private string payerName;
|
||||
private string phone;
|
||||
private string payerEmail;
|
||||
private string amount;
|
||||
private HairCutGenders gender;
|
||||
private string date;
|
||||
private string lieu;
|
||||
private string clientFinal;
|
||||
private string token;
|
||||
private string payerId;
|
||||
|
||||
public string CreateBody()
|
||||
{
|
||||
return $@"# Paiment confirmé: {amount}
|
||||
|
||||
Effectué par : {payerName} [{payerEmail}]
|
||||
Identifiant PayPal du paiment: {token}
|
||||
Identifiant PayPal du payeur: {payerId}
|
||||
Identifiant de la facture sur site: {invoiceId}
|
||||
|
||||
|
||||
# La prestation concernée:
|
||||
|
||||
Demandeur: {query.Client.UserName}
|
||||
|
||||
Date: {date}
|
||||
|
||||
Lieu: {lieu}
|
||||
|
||||
Le client final: {clientFinal}
|
||||
|
||||
{query.GetBillText()}
|
||||
|
||||
";
|
||||
}
|
||||
}
|
||||
}
|
@ -10,6 +10,9 @@ using System.Globalization;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models.Messaging;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Yavsc.ViewModels.PayPal;
|
||||
using Yavsc.Models.HairCut;
|
||||
|
||||
namespace Yavsc.Models.Haircut
|
||||
{
|
||||
@ -369,9 +372,15 @@ Prestation.Gender == HairCutGenders.Women ?
|
||||
return bill;
|
||||
}
|
||||
|
||||
public HairCutPayementEvent CreatePaymentEvent(PaymentInfo info, IStringLocalizer localizer)
|
||||
{
|
||||
|
||||
return new HairCutPayementEvent(Client.UserName,info,this, localizer);
|
||||
}
|
||||
|
||||
public virtual BrusherProfile SelectedProfile { get; set; }
|
||||
|
||||
public HairCutQueryEvent CreateEvent(string subTopic, string reason, string sender, string message) {
|
||||
public HairCutQueryEvent CreateEvent(string subTopic, string reason, string sender) {
|
||||
|
||||
string evdate = EventDate?.ToString("dddd dd/MM/yyyy à HH:mm")??"[pas de date spécifiée]";
|
||||
string address = Location?.Address??"[pas de lieu spécifié]";
|
||||
@ -393,8 +402,7 @@ Prestation.Gender == HairCutGenders.Women ?
|
||||
Id = Id,
|
||||
ActivityCode = ActivityCode,
|
||||
Reason = reason,
|
||||
Sender = sender,
|
||||
Message = message
|
||||
Sender = Client.GetSender()
|
||||
};
|
||||
return yaev;
|
||||
}
|
||||
|
@ -6,14 +6,20 @@ namespace Yavsc.Models.Haircut
|
||||
{
|
||||
public HairCutQueryEvent(string subTopic)
|
||||
{
|
||||
|
||||
Topic = GetType().Name+"/"+subTopic;
|
||||
Topic = "/topic/HairCutQuery";
|
||||
if (subTopic!=null) Topic+="/"+subTopic;
|
||||
}
|
||||
public string Message
|
||||
public string CreateBody()
|
||||
{
|
||||
get;
|
||||
return $"{Reason}\r\n-- \r\n{Previsional}\r\n{EventDate}\r\n";
|
||||
}
|
||||
|
||||
set;
|
||||
public string CreateBoby()
|
||||
{
|
||||
return string.Format(Startup.GlobalLocalizer["RdvToPerf"], Client.UserName,
|
||||
EventDate?.ToString("dddd dd/MM/yyyy à HH:mm"),
|
||||
Location.Address,
|
||||
ActivityCode);
|
||||
}
|
||||
|
||||
public string Sender
|
||||
|
@ -4,7 +4,7 @@ using Yavsc.Interfaces;
|
||||
|
||||
namespace Yavsc.Models.Messaging
|
||||
{
|
||||
public enum Reason {
|
||||
public enum Reason: byte {
|
||||
Private,
|
||||
Corporate,
|
||||
SearchingAPro,
|
||||
@ -23,6 +23,12 @@ namespace Yavsc.Models.Messaging
|
||||
public string OwnerId { get; set; }
|
||||
|
||||
[ForeignKey("OwnerId")]
|
||||
public virtual ApplicationUser Owner { get; set; }
|
||||
public virtual ApplicationUser Owner { get; set; }
|
||||
|
||||
public string Message { get; set; }
|
||||
public override string CreateBody()
|
||||
{
|
||||
return $"Annonce de {Owner.UserName}: {For}\n\n{Message}";
|
||||
}
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ namespace Yavsc.Models.Messaging
|
||||
/// /// Base event.
|
||||
/// </summary>
|
||||
|
||||
public class BaseEvent : IEvent {
|
||||
public abstract class BaseEvent : IEvent {
|
||||
public BaseEvent()
|
||||
{
|
||||
Topic = GetType().Name;
|
||||
@ -39,7 +39,8 @@ namespace Yavsc.Models.Messaging
|
||||
}
|
||||
public string Topic { get; private set; }
|
||||
public string Sender { get; set; }
|
||||
public string Message { get; set; }
|
||||
|
||||
abstract public string CreateBody();
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace Yavsc.Models.Messaging
|
||||
/// <summary>
|
||||
/// Event pub.
|
||||
/// </summary>
|
||||
public class CircleEvent: YaEvent
|
||||
public class CircleEvent: BaseEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the circles.
|
||||
@ -37,7 +37,12 @@ namespace Yavsc.Models.Messaging
|
||||
[Required(ErrorMessageResourceName="DoSpecifyCircles"),
|
||||
Display(Name="Circles")]
|
||||
public virtual List<Circle> Circles{ get; set; }
|
||||
}
|
||||
|
||||
public override string CreateBody()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ namespace Yavsc.Models.Messaging
|
||||
using Interfaces.Workflow;
|
||||
using Billing;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models.Workflow;
|
||||
|
||||
public class EstimationEvent: IEvent
|
||||
{
|
||||
@ -14,7 +15,7 @@ namespace Yavsc.Models.Messaging
|
||||
{
|
||||
Topic = "Estimation";
|
||||
Estimation = estimate;
|
||||
var perfer = context.Performers.Include(
|
||||
perfer = context.Performers.Include(
|
||||
p=>p.Performer
|
||||
).FirstOrDefault(
|
||||
p => p.PerformerId == estimate.OwnerId
|
||||
@ -27,12 +28,16 @@ namespace Yavsc.Models.Messaging
|
||||
UserId = perfer.PerformerId
|
||||
};
|
||||
Sender = perfer.Performer.UserName;
|
||||
Message = string.Format(SR["EstimationMessageToClient"],perfer.Performer.UserName,
|
||||
estimate.Title,estimate.Bill.Addition());
|
||||
_localizer = SR;
|
||||
}
|
||||
// TODO via e-mail only: Message = string.Format(
|
||||
// SR["EstimationMessageToClient"],perfer.Performer.UserName, estimate.Title,estimate.Bill.Addition());
|
||||
//
|
||||
ProviderClientInfo ProviderInfo { get; set; }
|
||||
Estimate Estimation { get; set; }
|
||||
|
||||
private PerformerProfile perfer;
|
||||
|
||||
public string Topic
|
||||
{
|
||||
get; set;
|
||||
@ -43,9 +48,11 @@ namespace Yavsc.Models.Messaging
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string Message
|
||||
private IStringLocalizer _localizer;
|
||||
|
||||
public string CreateBody()
|
||||
{
|
||||
get; set;
|
||||
return string.Format(_localizer["EstimationMessageToClient"], perfer.Performer.UserName, this.Estimation.Bill.Addition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,43 +0,0 @@
|
||||
//
|
||||
// BaseEvent.cs
|
||||
//
|
||||
// Author:
|
||||
// Paul Schneider <paul@pschneider.fr>
|
||||
//
|
||||
// Copyright (c) 2015 GNU GPL
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Yavsc.Models.Messaging
|
||||
{
|
||||
public class GeneralEvent: BaseEvent, ITitle
|
||||
{
|
||||
/// <summary>
|
||||
/// The title.
|
||||
/// </summary>
|
||||
[Required(ErrorMessageResourceName="ChooseATitle")]
|
||||
[Display(Name="Title")]
|
||||
public string Title { get; set; }
|
||||
/// <summary>
|
||||
/// The description.
|
||||
/// </summary>
|
||||
[Required(ErrorMessageResourceName="ChooseADescription")]
|
||||
[Display(Name="Description")]
|
||||
public string Description { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -22,20 +22,19 @@
|
||||
namespace Yavsc.Models.Messaging
|
||||
{
|
||||
using Interfaces.Workflow;
|
||||
using Yavsc.Abstract.Messaging;
|
||||
|
||||
|
||||
|
||||
public class RdvQueryEvent: RdvQueryProviderInfo, IEvent
|
||||
public class RdvQueryEvent: RdvQueryProviderInfo, IEvent
|
||||
{
|
||||
public string SubTopic
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public RdvQueryEvent(string subTopic)
|
||||
{
|
||||
Topic = GetType().Name+"/"+subTopic;
|
||||
}
|
||||
|
||||
public string Message
|
||||
{
|
||||
get; set;
|
||||
Topic = MessagingConstants.TopicRdvQuery;
|
||||
SubTopic = subTopic;
|
||||
}
|
||||
|
||||
public string Sender
|
||||
@ -47,6 +46,14 @@ public class RdvQueryEvent: RdvQueryProviderInfo, IEvent
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public string CreateBody()
|
||||
{
|
||||
return string.Format(Startup.GlobalLocalizer["RdvToPerf"], Client.UserName,
|
||||
EventDate?.ToString("dddd dd/MM/yyyy à HH:mm"),
|
||||
Location.Address,
|
||||
ActivityCode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,48 +0,0 @@
|
||||
//
|
||||
// NFEvent.cs
|
||||
//
|
||||
// Author:
|
||||
// Paul Schneider <paulschneider@free.fr>
|
||||
//
|
||||
// Copyright (c) 2015 Paul Schneider
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Yavsc.Models.Messaging
|
||||
{
|
||||
/// <summary>
|
||||
/// NF event.
|
||||
/// </summary>
|
||||
public class YaEvent : BaseEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// The NF provider identifier.
|
||||
/// </summary>
|
||||
[Display(Name="From")]
|
||||
public string FromUserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The event web page.
|
||||
/// </summary>
|
||||
[Display(Name="EventWebPage")]
|
||||
public string EventWebPage { get; set; }
|
||||
/// <summary>
|
||||
/// The image locator.
|
||||
/// </summary>
|
||||
[Display(Name="Photo")]
|
||||
public string Photo { get; set; }
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ namespace Yavsc.Models.Relationship
|
||||
/// <summary>
|
||||
/// Position.
|
||||
/// </summary>
|
||||
public class Position
|
||||
public class Position: IPosition
|
||||
{
|
||||
/// <summary>
|
||||
/// The longitude.
|
||||
|
Reference in New Issue
Block a user