diff --git a/Yavsc/Controllers/Contracting/CommandController.cs b/Yavsc/Controllers/Contracting/CommandController.cs index ebe35ed6..761185e0 100644 --- a/Yavsc/Controllers/Contracting/CommandController.cs +++ b/Yavsc/Controllers/Contracting/CommandController.cs @@ -169,23 +169,38 @@ namespace Yavsc.Controllers if (pro.AcceptNotifications && pro.AcceptPublicContact) { + + try { if (pro.Performer.Devices.Count > 0) { var regids = command.PerformerProfile.Performer .Devices.Select(d => d.GCMRegistrationId); grep = await _GCMSender.NotifyBookQueryAsync(regids,yaev); } - + + _logger.LogError("sending GCM"); + // TODO setup a profile choice to allow notifications // both on mailbox and mobile // if (grep==null || grep.success<=0 || grep.failure>0) ViewBag.GooglePayload=grep; + } + catch (Exception ex) + { + _logger.LogError(ex.Message); + } + try { ViewBag.EmailSent = await _emailSender.SendEmailAsync( command.PerformerProfile.Performer.UserName, command.PerformerProfile.Performer.Email, $"{command.Client.UserName} (un client) vous demande un rendez-vous", $"{yaev.CreateBody()}\r\n-- \r\n{yaev.Previsional}\r\n{yaev.EventDate}\r\n" ); + } + catch (Exception ex) + { + _logger.LogError(ex.Message); + } } ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == command.ActivityCode); ViewBag.GoogleSettings = _googleSettings; diff --git a/Yavsc/Services/MailSender.cs b/Yavsc/Services/MailSender.cs index e2c0ebd6..5a7bdc22 100644 --- a/Yavsc/Services/MailSender.cs +++ b/Yavsc/Services/MailSender.cs @@ -64,6 +64,7 @@ namespace Yavsc.Services SecureSocketOptions.None); await sc.SendAsync(msg); model.MessageId = msg.MessageId; + model.Sent = true; // a duplicate info to remove from the view model, that equals to MessageId == null } } catch (Exception ex) @@ -76,4 +77,4 @@ namespace Yavsc.Services } } -} \ No newline at end of file +} diff --git a/Yavsc/Views/Command/CommandConfirmation.cshtml b/Yavsc/Views/Command/CommandConfirmation.cshtml index 4e962d16..0643e3f8 100644 --- a/Yavsc/Views/Command/CommandConfirmation.cshtml +++ b/Yavsc/Views/Command/CommandConfirmation.cshtml @@ -26,9 +26,21 @@ } } } - @if (ViewBag.EmailSent.Sent) + @if (ViewBag.EmailSent!=null) { +if (ViewBag.EmailSent.Sent) {