remove Google validation of the adress, and give email sending status
This commit is contained in:
parent
a82e6c4998
commit
0f38aa6024
4 changed files with 47 additions and 108 deletions
|
|
@ -169,23 +169,38 @@ namespace Yavsc.Controllers
|
||||||
if (pro.AcceptNotifications
|
if (pro.AcceptNotifications
|
||||||
&& pro.AcceptPublicContact)
|
&& pro.AcceptPublicContact)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
try {
|
||||||
if (pro.Performer.Devices.Count > 0) {
|
if (pro.Performer.Devices.Count > 0) {
|
||||||
var regids = command.PerformerProfile.Performer
|
var regids = command.PerformerProfile.Performer
|
||||||
.Devices.Select(d => d.GCMRegistrationId);
|
.Devices.Select(d => d.GCMRegistrationId);
|
||||||
grep = await _GCMSender.NotifyBookQueryAsync(regids,yaev);
|
grep = await _GCMSender.NotifyBookQueryAsync(regids,yaev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_logger.LogError("sending GCM");
|
||||||
|
|
||||||
// TODO setup a profile choice to allow notifications
|
// TODO setup a profile choice to allow notifications
|
||||||
// both on mailbox and mobile
|
// both on mailbox and mobile
|
||||||
// if (grep==null || grep.success<=0 || grep.failure>0)
|
// if (grep==null || grep.success<=0 || grep.failure>0)
|
||||||
ViewBag.GooglePayload=grep;
|
ViewBag.GooglePayload=grep;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
ViewBag.EmailSent = await _emailSender.SendEmailAsync(
|
ViewBag.EmailSent = await _emailSender.SendEmailAsync(
|
||||||
command.PerformerProfile.Performer.UserName,
|
command.PerformerProfile.Performer.UserName,
|
||||||
command.PerformerProfile.Performer.Email,
|
command.PerformerProfile.Performer.Email,
|
||||||
$"{command.Client.UserName} (un client) vous demande un rendez-vous",
|
$"{command.Client.UserName} (un client) vous demande un rendez-vous",
|
||||||
$"{yaev.CreateBody()}\r\n-- \r\n{yaev.Previsional}\r\n{yaev.EventDate}\r\n"
|
$"{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.Activity = _context.Activities.FirstOrDefault(a=>a.Code == command.ActivityCode);
|
||||||
ViewBag.GoogleSettings = _googleSettings;
|
ViewBag.GoogleSettings = _googleSettings;
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ namespace Yavsc.Services
|
||||||
SecureSocketOptions.None);
|
SecureSocketOptions.None);
|
||||||
await sc.SendAsync(msg);
|
await sc.SendAsync(msg);
|
||||||
model.MessageId = msg.MessageId;
|
model.MessageId = msg.MessageId;
|
||||||
|
model.Sent = true; // a duplicate info to remove from the view model, that equals to MessageId == null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,21 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@if (ViewBag.EmailSent.Sent)
|
@if (ViewBag.EmailSent!=null)
|
||||||
{
|
{
|
||||||
|
if (ViewBag.EmailSent.Sent) {
|
||||||
<h4>@String.Format(SR["EmailSentToPerformer"],User.GetUserName())</h4>
|
<h4>@String.Format(SR["EmailSentToPerformer"],User.GetUserName())</h4>
|
||||||
|
} else {
|
||||||
|
var sent = ViewBag.EmailSent;
|
||||||
|
|
||||||
|
<h4>Une erreur est survenue à lenvoi de l'e-mail au préstataire ...</h4>
|
||||||
|
<environment names="Development">
|
||||||
|
<text>Mail:</text> @sent.EMail;
|
||||||
|
<text>MsgId:</text> @sent.MessageId;
|
||||||
|
<text>Sent:</text> @sent.Sent;
|
||||||
|
<text>Error:</text> @sent.ErrorMessage;
|
||||||
|
</environment>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,17 @@
|
||||||
@model RdvQuery
|
@model RdvQuery
|
||||||
@{ ViewData["Title"] = $"Proposition de rendez-vous à {Model.PerformerProfile.Performer.UserName} [{ViewBag.Activity.Name}]"; }
|
@{ ViewData["Title"] = $"Proposition de rendez-vous à {Model.PerformerProfile.Performer.UserName} [{ViewBag.Activity.Name}]"; }
|
||||||
|
|
||||||
<script src="https://maps.googleapis.com/maps/api/js?key=@ViewBag.GoogleSettings.BrowserApiKey"></script>
|
|
||||||
<script type="text/javascript" src="~/lib/moment/moment-with-locales.min.js"></script>
|
<script type="text/javascript" src="~/lib/moment/moment-with-locales.min.js"></script>
|
||||||
<script type="text/javascript" src="~/lib/eonasdan-bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
|
<script type="text/javascript" src="~/lib/eonasdan-bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
|
||||||
<link rel="stylesheet" href="~/lib/eonasdan-bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
|
<link rel="stylesheet" href="~/lib/eonasdan-bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
|
||||||
@section header {
|
@section header {
|
||||||
<style>
|
<style>
|
||||||
#map {
|
html, body {
|
||||||
width: 100%;
|
height: 100%;
|
||||||
height: 250px;
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
}
|
}
|
||||||
#Location_combo li {
|
</style>
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
#Location_combo li:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
}
|
}
|
||||||
@section scripts {
|
@section scripts {
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -29,102 +22,18 @@
|
||||||
format: "YYYY/MM/DD HH:mm"
|
format: "YYYY/MM/DD HH:mm"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
initMap();
|
||||||
|
|
||||||
var config = {
|
|
||||||
mapId: 'map',
|
|
||||||
addrId: 'Location_Address',
|
|
||||||
longId: 'Location_Longitude',
|
|
||||||
latId: 'Location_Latitude',
|
|
||||||
addrValidationId: 'valloc',
|
|
||||||
formValidId: 'valsum',
|
|
||||||
locComboId: 'loccomb'
|
|
||||||
};
|
|
||||||
|
|
||||||
$.validator.setDefaults({
|
|
||||||
messages: {
|
|
||||||
remote: "Ce lieu n'est pas identifié par les services de géo-localisation Google",
|
|
||||||
required: "Veuillez renseigner ce champ"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
var gmap = new google.maps.Map(document.getElementById(config.mapId), {
|
|
||||||
zoom: 16,
|
|
||||||
center: { lat: 48.862854, lng: 2.2056466 }
|
|
||||||
});
|
|
||||||
var marker;
|
|
||||||
function chooseLoc(sender, loc) {
|
|
||||||
if (sender === 'user') $('#' + config.addrId).val(loc.formatted_address);
|
|
||||||
var pos = loc.geometry.location;
|
|
||||||
var lat = new Number(pos.lat);
|
|
||||||
var lng = new Number(pos.lng);
|
|
||||||
$('#' + config.latId).val(lat.toLocaleString('en'));
|
|
||||||
$('#' + config.longId).val(lng.toLocaleString('en'));
|
|
||||||
gmap.setCenter(pos);
|
|
||||||
if (marker) {
|
|
||||||
marker.setMap(null);
|
|
||||||
}
|
|
||||||
marker = new google.maps.Marker({
|
|
||||||
map: gmap,
|
|
||||||
draggable: true,
|
|
||||||
animation: google.maps.Animation.DROP,
|
|
||||||
position: pos
|
|
||||||
});
|
|
||||||
google.maps.event.addListener(marker, 'dragend', function () {
|
|
||||||
// TODO reverse geo code
|
|
||||||
var pos = marker.getPosition();
|
|
||||||
$('#' + config.latId).val(pos.lat);
|
|
||||||
$('#' + config.longId).val(pos.lng);
|
|
||||||
});
|
|
||||||
$('#' + config.addrId).valid();
|
|
||||||
$('#' + config.addrValidationId).empty();
|
|
||||||
$('#' + config.formValidId).empty();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$('#' + config.addrId).rules("add",
|
|
||||||
{
|
|
||||||
remote: {
|
|
||||||
url: 'https://maps.googleapis.com/maps/api/geocode/json',
|
|
||||||
type: 'get',
|
|
||||||
data: {
|
|
||||||
sensor: false,
|
|
||||||
address: function () { return $('#' + config.addrId).val() }
|
|
||||||
},
|
|
||||||
dataType: 'json',
|
|
||||||
dataFilter: function (datastr, type) {
|
|
||||||
$('#' + config.locComboId).html("");
|
|
||||||
var data = JSON.parse(datastr);
|
|
||||||
data.results.forEach(function (element) {
|
|
||||||
if (element.formatted_address !== $('#' + config.addrId).val()) {
|
|
||||||
$('<li>' + element.formatted_address + '</li>')
|
|
||||||
.data("geoloc", element)
|
|
||||||
.click(function () { chooseLoc('user', $(this).data("geoloc")) })
|
|
||||||
.appendTo($('#' + config.locComboId));
|
|
||||||
}
|
|
||||||
else { }
|
|
||||||
});
|
|
||||||
if ((data.status === 'OK') && (data.results.length == 1)) {
|
|
||||||
chooseLoc('google', data.results[0]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
error: function (xhr, textStatus, errorThrown) {
|
|
||||||
console.log('ajax loading error ... ' + textStatus + ' ... ' + errorThrown);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
<h2>@ViewData["Title"]</h2>
|
<h2>@ViewData["Title"]</h2>
|
||||||
<form asp-action="Create" id="FrmComCre" role="form">
|
<form asp-action="Create" method="post">
|
||||||
<div class="form-horizontal">
|
<div class="form-horizontal">
|
||||||
<h4>Saisissez votre demande de rendez-vous</h4>
|
<h4>Saisissez votre demande de rendez-vous</h4>
|
||||||
<hr />
|
<hr />
|
||||||
<div asp-validation-summary="ValidationSummary.All" class="text-danger" id="valsum"></div>
|
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
|
||||||
<div class="form-group" has-feedback>
|
<div class="form-group" has-feedback>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Votre évennement</legend>
|
<legend>Votre évennement</legend>
|
||||||
|
|
@ -157,12 +66,12 @@
|
||||||
<div class='col-sm-6'>
|
<div class='col-sm-6'>
|
||||||
<div >
|
<div >
|
||||||
<input asp-for="Location.Address" type="text" name="Location.Address" id="Location_Address" class="form-control"
|
<input asp-for="Location.Address" type="text" name="Location.Address" id="Location_Address" class="form-control"
|
||||||
data-val-required="Spécifier un lieu" data-val-remote="Google n'a pas pu identifier ce lieu">
|
data-val-required="Spécifier un lieu" >
|
||||||
<span asp-validation-for="Location.Address" class="text-danger" id="valloc"></span>
|
<span asp-validation-for="Location.Address" class="text-danger"></span>
|
||||||
<ul id="loccomb">
|
<ul id="loccomb">
|
||||||
</ul>
|
</ul>
|
||||||
<div id="map"></div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -190,8 +99,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-md-offset-2 col-md-10">
|
<div class="col-md-offset-2 col-md-10">
|
||||||
<input type="submit" value="Créer" class="btn btn-default" />
|
|
||||||
</div>
|
<input type="submit" class="btn btn-default" value="Créer"></input>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@Html.HiddenFor(model=>model.ClientId)
|
@Html.HiddenFor(model=>model.ClientId)
|
||||||
@Html.HiddenFor(model=>model.PerformerId)
|
@Html.HiddenFor(model=>model.PerformerId)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue