refactoring messages
This commit is contained in:
parent
6066497a67
commit
13bdf7463d
44 changed files with 602 additions and 303 deletions
|
|
@ -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; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue