diff --git a/Yavsc/Controllers/CommandController.cs b/Yavsc/Controllers/CommandController.cs
index fe2a4277..23f93442 100644
--- a/Yavsc/Controllers/CommandController.cs
+++ b/Yavsc/Controllers/CommandController.cs
@@ -60,7 +60,6 @@ namespace Yavsc.Controllers
.Include(x => x.PerformerProfile)
.Include(x => x.PerformerProfile.Performer)
.Include(x => x.Location)
- .Include(x => x.Bill)
.Where(x=> x.ClientId == uid || x.PerformerId == uid)
.ToList());
}
@@ -135,6 +134,7 @@ namespace Yavsc.Controllers
.FirstOrDefault(
x => x.PerformerId == command.PerformerId
);
+ _logger.LogDebug($"Pro: {pro}");
command.PerformerProfile = pro;
var user = await _userManager.FindByIdAsync(
User.GetUserId()
@@ -162,7 +162,7 @@ namespace Yavsc.Controllers
var regids = command.PerformerProfile.Performer
.Devices.Select(d => d.GCMRegistrationId);
var sregids = string.Join(",",regids);
- grep = await _GCMSender.NotifyAsync(_googleSettings,regids,yaev);
+ grep = await _GCMSender.NotifyBookQueryAsync(_googleSettings,regids,yaev);
}
// TODO setup a profile choice to allow notifications
// both on mailbox and mobile
@@ -174,8 +174,8 @@ namespace Yavsc.Controllers
await _emailSender.SendEmailAsync(
_siteSettings, _smtpSettings,
command.PerformerProfile.Performer.Email,
- yaev.Title,
- $"{yaev.Description}\r\n-- \r\n{yaev.Comment}\r\n"
+ yaev.Topic+" "+yaev.Client.UserName,
+ $"{yaev.Message}\r\n-- \r\n{yaev.Previsional}\r\n"
);
}
ViewBag.GoogleSettings = _googleSettings;
diff --git a/Yavsc/Helpers/EventHelpers.cs b/Yavsc/Helpers/EventHelpers.cs
index 5277706d..fbdb614a 100644
--- a/Yavsc/Helpers/EventHelpers.cs
+++ b/Yavsc/Helpers/EventHelpers.cs
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Localization;
+using Yavsc.Model;
using Yavsc.Models.Booking;
using Yavsc.Models.Messaging;
@@ -11,17 +12,14 @@ namespace Yavsc.Helpers
{
var yaev = new BookQueryEvent
{
- Title = query.Client.UserName + " "+ SR["is asking you for a date"]+".",
- Comment = (query.Previsional != null) ?
- SR["Deposit"] + string.Format(": {0:00}",
- query.Previsional) : SR["No deposit."],
- Description = SR["Address"] + ": " + query.Location.Address + "\n" +
- SR["Date"] + ": " + query.EventDate.ToString("D"),
- StartDate = query.EventDate,
+ Client = new ClientProviderView { UserName = query.Client.UserName , UserId = query.ClientId } ,
+ Previsional = query.Previsional,
+ EventDate = query.EventDate,
Location = query.Location,
- CommandId = query.Id
+ Id = query.Id
};
return yaev;
}
+
}
}
diff --git a/Yavsc/Helpers/GoogleHelpers.cs b/Yavsc/Helpers/GoogleHelpers.cs
index efcaab23..dc82df0b 100644
--- a/Yavsc/Helpers/GoogleHelpers.cs
+++ b/Yavsc/Helpers/GoogleHelpers.cs
@@ -21,11 +21,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Net.Http;
-using System.Net.Http.Headers;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
-using Newtonsoft.Json.Linq;
using Yavsc.Models;
using Yavsc.Models.Auth;
using Yavsc.Models.Google.Messaging;
@@ -37,7 +34,7 @@ namespace Yavsc.Helpers
///
public static class GoogleHelpers
{
-
+/* WAZA
///
/// Notifies the event.
///
@@ -70,18 +67,17 @@ namespace Yavsc.Helpers
var payload = JObject.Parse(await response.Content.ReadAsStringAsync());
return payload.Value();
}
-
+*/
public static MessageWithPayloadResponse NotifyEvent
(this GoogleAuthSettings googleSettings, IEnumerable regids, Event ev)
- where Event : YaEvent
+ where Event : IEvent
{
var msg = new MessageWithPayload()
{
notification = new Notification()
{
- title = ev.Title,
- body = ev.Description + ev.Comment == null ?
- "" : "(" + ev.Comment + ")",
+ title = ev.Topic+" "+ev.Sender,
+ body = ev.Message,
icon = "icon"
},
data = ev,
diff --git a/Yavsc/Interfaces/IEvent.cs b/Yavsc/Interfaces/IEvent.cs
new file mode 100644
index 00000000..6ee109e7
--- /dev/null
+++ b/Yavsc/Interfaces/IEvent.cs
@@ -0,0 +1,14 @@
+
+
+public interface IEvent {
+ ///
+ /// An acceptable topic for this event to be.
+ /// Should return something like the class name
+ /// of this object
+ ///
+ ///
+ string Topic { get; set ; }
+ string Sender { get; set ; }
+
+ string Message { get; set; }
+}
\ No newline at end of file
diff --git a/Yavsc/Model/Booking/BookQuery.cs b/Yavsc/Model/Booking/BookQuery.cs
index b8f787c8..1e69785a 100644
--- a/Yavsc/Model/Booking/BookQuery.cs
+++ b/Yavsc/Model/Booking/BookQuery.cs
@@ -18,29 +18,22 @@ namespace Yavsc.Models.Booking
[Display(Name="Event date")]
public DateTime EventDate{
- get
- { return ((RendezVous)Bill[0]).EventDate; }
- set { ((RendezVous)Bill[0]).EventDate = value; }
+ get;
+ set;
}
public Location Location {
- get
- { return ((RendezVous)Bill[0]).Location; }
- set { ((RendezVous)Bill[0]).Location = value; }}
+ get;
+ set;
+ }
public BookQuery()
{
- this.Bill.Add(new RendezVous());
}
public BookQuery(Location eventLocation, DateTime eventDate)
{
- this.Bill.Add(new RendezVous{
- Location = eventLocation,
- EventDate = eventDate
- });
- }
- public string GetDescription() {
- return $"{Location?.Address} {EventDate.ToString()}";
+ Location = eventLocation;
+ EventDate = eventDate;
}
}
}
\ No newline at end of file
diff --git a/Yavsc/Model/Calendar/ProvidedEvent.cs b/Yavsc/Model/Calendar/ProvidedEvent.cs
index f20e2246..837bdf50 100644
--- a/Yavsc/Model/Calendar/ProvidedEvent.cs
+++ b/Yavsc/Model/Calendar/ProvidedEvent.cs
@@ -30,13 +30,6 @@ namespace Yavsc.Models.Calendar
/// Provided event.
///
public class ProvidedEvent : YaEvent {
-
- public ProvidedEvent(string topic) : base(topic)
- {
-
- }
-
-
///
/// The privacy.
///
diff --git a/Yavsc/Model/Messaging/BaseEvent.cs b/Yavsc/Model/Messaging/BaseEvent.cs
index 19c2db10..ea946638 100644
--- a/Yavsc/Model/Messaging/BaseEvent.cs
+++ b/Yavsc/Model/Messaging/BaseEvent.cs
@@ -27,7 +27,23 @@ namespace Yavsc.Models.Messaging
///
/// Base event.
///
- public class BaseEvent: ITitle
+
+ public class BaseEvent : IEvent {
+ public BaseEvent()
+ {
+ Topic = GetType().Name;
+ }
+ public BaseEvent(string topic)
+ {
+ Topic = topic;
+ }
+ public string Topic { get; set; }
+ public string Sender { get; set; }
+
+ public string Message { get; set; }
+ }
+
+ public class GeneralEvent: BaseEvent, ITitle
{
///
/// The title.
diff --git a/Yavsc/Model/Messaging/BookQueryEvent.cs b/Yavsc/Model/Messaging/BookQueryEvent.cs
index 53f5b40c..060e2677 100644
--- a/Yavsc/Model/Messaging/BookQueryEvent.cs
+++ b/Yavsc/Model/Messaging/BookQueryEvent.cs
@@ -1,8 +1,7 @@
-using System;
-using System.ComponentModel.DataAnnotations;
namespace Yavsc.Models.Messaging
{
+using Yavsc.Model;
//
// BookQueryEvent.cs
@@ -25,31 +24,27 @@ namespace Yavsc.Models.Messaging
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see .
-public class BookQueryEvent: YaEvent
+public class BookQueryEvent: BookQueryProviderView, IEvent
{
- public BookQueryEvent() : base("BookQuery")
+ public BookQueryEvent()
{
-
+ Topic = "BookQuery";
}
- ///
- /// The location.
- ///
- [Display(Name="Location")]
- public Location Location { get; set; }
- ///
- /// The start date.
- ///
- [Display(Name="StartDate")]
- public DateTime StartDate { get; set; }
- ///
- /// Gets or sets the end date.
- ///
- /// The end date.
- [Display(Name="EndDate")]
- public DateTime EndDate { get; set; }
+ public string Message
+ {
+ get; set;
+ }
- public long CommandId { get; set; }
- }
+ public string Sender
+ {
+ get; set;
+ }
+
+ public string Topic
+ {
+ get; set;
+ }
+ }
}
diff --git a/Yavsc/Model/Messaging/CircleEvent.cs b/Yavsc/Model/Messaging/CircleEvent.cs
index f9317eb5..ad9de407 100644
--- a/Yavsc/Model/Messaging/CircleEvent.cs
+++ b/Yavsc/Model/Messaging/CircleEvent.cs
@@ -29,11 +29,6 @@ namespace Yavsc.Models.Messaging
///
public class CircleEvent: YaEvent
{
- public CircleEvent(string topic) : base(topic)
- {
-
- }
-
///
/// Gets or sets the circles.
///
diff --git a/Yavsc/Model/Messaging/ClientProviderInfo.cs b/Yavsc/Model/Messaging/ClientProviderInfo.cs
new file mode 100644
index 00000000..7febd680
--- /dev/null
+++ b/Yavsc/Model/Messaging/ClientProviderInfo.cs
@@ -0,0 +1,21 @@
+
+using System;
+namespace Yavsc.Model
+{
+
+public class BookQueryProviderView {
+ public ClientProviderView Client { get; set; }
+ public Location Location { get; set; }
+
+ public long Id { get; set; }
+
+ public DateTime EventDate { get ; set; }
+ public decimal? Previsional { get; set; }
+ }
+ public class ClientProviderView {
+ public string UserName { get; set; }
+ public string UserId { get; set; }
+ public int Rate { get; set; }
+ }
+
+}
\ No newline at end of file
diff --git a/Yavsc/Model/Messaging/YaEvent.cs b/Yavsc/Model/Messaging/YaEvent.cs
index aca7190b..ce7304bd 100644
--- a/Yavsc/Model/Messaging/YaEvent.cs
+++ b/Yavsc/Model/Messaging/YaEvent.cs
@@ -28,24 +28,12 @@ namespace Yavsc.Models.Messaging
///
public class YaEvent : BaseEvent
{
- public YaEvent(string topic)
- {
- Topic = topic;
- }
- ///
- /// The topic.
- ///
- public string Topic { get; set; }
///
/// The NF provider identifier.
///
- [Display(Name="ProviderId")]
- public string ProviderId { get; set; }
- ///
- /// The promotion code.
- ///
- [Display(Name="Comment")]
- public string Comment { get; set; }
+ [Display(Name="From")]
+ public string FromUserName { get; set; }
+
///
/// The event web page.
///
diff --git a/Yavsc/Services/IGoogleCloudMessageSender.cs b/Yavsc/Services/IGoogleCloudMessageSender.cs
index b4db0123..033759c7 100644
--- a/Yavsc/Services/IGoogleCloudMessageSender.cs
+++ b/Yavsc/Services/IGoogleCloudMessageSender.cs
@@ -8,6 +8,6 @@ namespace Yavsc.Services
{
public interface IGoogleCloudMessageSender
{
- Task NotifyAsync(GoogleAuthSettings googlesettings, IEnumerable registrationId, YaEvent ev);
+ Task NotifyBookQueryAsync(GoogleAuthSettings googlesettings, IEnumerable registrationId, BookQueryEvent ev);
}
}
diff --git a/Yavsc/Services/MessageServices.cs b/Yavsc/Services/MessageServices.cs
index c9d7b5b6..33f54fd1 100755
--- a/Yavsc/Services/MessageServices.cs
+++ b/Yavsc/Services/MessageServices.cs
@@ -28,11 +28,11 @@ namespace Yavsc.Services
/// bool somethingsent = (response.failure == 0 && response.success > 0)
///
public async Task
- NotifyAsync(GoogleAuthSettings googleSettings, IEnumerable registrationIds, YaEvent ev)
+ NotifyBookQueryAsync(GoogleAuthSettings googleSettings, IEnumerable registrationIds, BookQueryEvent ev)
{
MessageWithPayloadResponse response = null;
await Task.Run(()=>{
- response = googleSettings.NotifyEvent(registrationIds, ev);
+ response = googleSettings.NotifyEvent(registrationIds, ev);
});
return response;
}