yavsc/Yavsc.Server/Models/Messaging/EstimationEvent.cs

58 lines
1.7 KiB
C#
Raw Normal View History

using System.Linq;
2017-02-22 22:58:02 +01:00
using Microsoft.Data.Entity;
using Microsoft.Extensions.Localization;
namespace Yavsc.Models.Messaging
{
2017-02-22 22:58:02 +01:00
using Interfaces.Workflow;
using Billing;
using Yavsc.Helpers;
2018-02-03 20:17:29 +01:00
using Yavsc.Models.Workflow;
2017-02-22 22:58:02 +01:00
public class EstimationEvent: IEvent
{
public EstimationEvent(ApplicationDbContext context, Estimate estimate, IStringLocalizer SR)
{
2017-02-22 22:58:02 +01:00
Topic = "Estimation";
Estimation = estimate;
2018-02-03 20:17:29 +01:00
perfer = context.Performers.Include(
2017-02-22 22:58:02 +01:00
p=>p.Performer
).FirstOrDefault(
p => p.PerformerId == estimate.OwnerId
);
// Use estimate.OwnerId;
ProviderInfo = new ProviderClientInfo {
Rate = perfer.Rate,
UserName = perfer.Performer.UserName,
Avatar = perfer.Performer.Avatar,
UserId = perfer.PerformerId
};
2017-03-02 23:47:44 +01:00
Sender = perfer.Performer.UserName;
2018-02-03 20:17:29 +01:00
_localizer = SR;
}
2018-02-03 20:17:29 +01:00
// 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; }
2018-02-03 20:17:29 +01:00
private PerformerProfile perfer;
2017-02-22 22:58:02 +01:00
public string Topic
{
2017-02-22 22:58:02 +01:00
get; set;
}
2017-02-22 22:58:02 +01:00
public string Sender
{
2017-02-22 22:58:02 +01:00
get; set;
}
2018-02-03 20:17:29 +01:00
private IStringLocalizer _localizer;
public string CreateBody()
{
2018-02-03 20:17:29 +01:00
return string.Format(_localizer["EstimationMessageToClient"], perfer.Performer.UserName, this.Estimation.Bill.Addition());
}
}
2017-06-02 10:13:55 +02:00
}