restores the legacy behavior

main
Paul Schneider 9 years ago
parent fff5efcdce
commit cdad56a806
5 changed files with 175 additions and 152 deletions

@ -55,7 +55,7 @@ namespace Yavsc.Controllers
.Include(x => x.PerformerProfile.Performer.Devices) .Include(x => x.PerformerProfile.Performer.Devices)
.Include(x => x.Regularisation) .Include(x => x.Regularisation)
.SingleAsync(m => m.Id == id); .SingleAsync(m => m.Id == id);
query.SelectedProfile = await _context.BrusherProfile.SingleAsync(b=>b.UserId == query.PerformerId); query.SelectedProfile = await _context.BrusherProfile.SingleAsync(b => b.UserId == query.PerformerId);
return query; return query;
} }
public async Task<IActionResult> ClientCancel(long id) public async Task<IActionResult> ClientCancel(long id)
@ -66,7 +66,7 @@ namespace Yavsc.Controllers
return HttpNotFound(); return HttpNotFound();
} }
SetViewBagPaymentUrls(id); SetViewBagPaymentUrls(id);
return View (command); return View(command);
} }
public async Task<IActionResult> PaymentConfirmation([FromRoute] long id, string token, string PayerID) public async Task<IActionResult> PaymentConfirmation([FromRoute] long id, string token, string PayerID)
{ {
@ -75,35 +75,35 @@ namespace Yavsc.Controllers
{ {
return HttpNotFound(); return HttpNotFound();
} }
var paymentInfo = await _context.ConfirmPayment( User.GetUserId(), PayerID, token ); var paymentInfo = await _context.ConfirmPayment(User.GetUserId(), PayerID, token);
ViewData["paymentinfo"] = paymentInfo; ViewData["paymentinfo"] = paymentInfo;
command.Regularisation = paymentInfo.DbContent; command.Regularisation = paymentInfo.DbContent;
command.PaymentId = token; command.PaymentId = token;
if (paymentInfo!=null) if (paymentInfo != null)
if (paymentInfo.DetailsFromPayPal!=null) if (paymentInfo.DetailsFromPayPal != null)
if (paymentInfo.DetailsFromPayPal.Ack == AckCodeType.SUCCESS) if (paymentInfo.DetailsFromPayPal.Ack == AckCodeType.SUCCESS)
if (command.ValidationDate ==null) if (command.ValidationDate == null)
command.ValidationDate = DateTime.Now; command.ValidationDate = DateTime.Now;
await _context.SaveChangesAsync (User.GetUserId()); await _context.SaveChangesAsync(User.GetUserId());
SetViewBagPaymentUrls(id); SetViewBagPaymentUrls(id);
if (command.PerformerProfile.AcceptPublicContact) if (command.PerformerProfile.AcceptPublicContact)
{ {
var invoiceId = paymentInfo.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.InvoiceID; var invoiceId = paymentInfo.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.InvoiceID;
var payerName = paymentInfo.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.Name; var payerName = paymentInfo.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.Name;
var phone = paymentInfo.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.Phone; var phone = paymentInfo.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Address.Phone;
var payerEmail = paymentInfo.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Payer; var payerEmail = paymentInfo.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.PayerInfo.Payer;
var amount = string.Join(", ", var amount = string.Join(", ",
paymentInfo.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.PaymentDetails.Select( paymentInfo.DetailsFromPayPal.GetExpressCheckoutDetailsResponseDetails.PaymentDetails.Select(
p=> $"{p.OrderTotal.value} {p.OrderTotal.currencyID}")); p => $"{p.OrderTotal.value} {p.OrderTotal.currencyID}"));
var gender = command.Prestation.Gender; var gender = command.Prestation.Gender;
var date = command.EventDate?.ToString("dd MM yyyy hh:mm"); var date = command.EventDate?.ToString("dd MM yyyy hh:mm");
var lieu = command.Location.Address; var lieu = command.Location.Address;
string clientFinal = (gender == HairCutGenders.Women) ? _localizer["Women"] + string clientFinal = (gender == HairCutGenders.Women) ? _localizer["Women"] +
" "+_localizer[command.Prestation.Length.ToString()] : _localizer[gender.ToString()] ; " " + _localizer[command.Prestation.Length.ToString()] : _localizer[gender.ToString()];
MessageWithPayloadResponse grep = null; MessageWithPayloadResponse grep = null;
var yaev = command.CreateEvent("PaymentConfirmation", var yaev = command.CreateEvent("PaymentConfirmation",
this._localizer["PaymentConfirmation"], this._localizer["PaymentConfirmation"],
command.Client.GetSender(), command.Client.GetSender(),
$@"# Paiment confirmé: {amount} $@"# Paiment confirmé: {amount}
Effectué par : {payerName} [{payerEmail}] Effectué par : {payerName} [{payerEmail}]
@ -126,52 +126,55 @@ Le client final: {clientFinal}
"); ");
if (command.PerformerProfile.AcceptNotifications) { if (command.PerformerProfile.AcceptNotifications)
if (command.PerformerProfile.Performer.Devices.Count > 0) { {
var regids = command.PerformerProfile.Performer if (command.PerformerProfile.Performer.Devices.Count > 0)
.Devices.Select(d => d.GCMRegistrationId); {
grep = await _GCMSender.NotifyHairCutQueryAsync(_googleSettings,regids,yaev); var regids = command.PerformerProfile.Performer
} .Devices.Select(d => d.GCMRegistrationId);
// TODO setup a profile choice to allow notifications grep = await _GCMSender.NotifyHairCutQueryAsync(_googleSettings, regids, yaev);
// both on mailbox and mobile }
// if (grep==null || grep.success<=0 || grep.failure>0) // TODO setup a profile choice to allow notifications
ViewBag.GooglePayload=grep; // both on mailbox and mobile
} // if (grep==null || grep.success<=0 || grep.failure>0)
ViewBag.GooglePayload = grep;
ViewBag.EmailSent = await _emailSender.SendEmailAsync(
_siteSettings, _smtpSettings,
command.PerformerProfile.Performer.Email,
yaev.Reason,
$"{yaev.Message}\r\n-- \r\n{yaev.Previsional}\r\n{yaev.EventDate}\r\n"
);
}
else {
// TODO if (AcceptProContact) try & find a bookmaker to send him this query
} }
ViewData ["Notify"] = new List<Notification> { ViewBag.EmailSent = await _emailSender.SendEmailAsync(
_siteSettings, _smtpSettings,
command.PerformerProfile.Performer.Email,
yaev.Reason,
$"{yaev.Message}\r\n-- \r\n{yaev.Previsional}\r\n{yaev.EventDate}\r\n"
);
}
else
{
// TODO if (AcceptProContact) try & find a bookmaker to send him this query
}
ViewData["Notify"] = new List<Notification> {
new Notification { new Notification {
title= "Paiment PayPal", title= "Paiment PayPal",
body = "Votre paiment a été accépté." body = "Votre paiment a été accépté."
} }
} ; };
return View ("Details",command); return View("Details", command);
} }
private void SetViewBagPaymentUrls(long id) private void SetViewBagPaymentUrls(long id)
{ {
ViewBag.CreatePaymentUrl = Request.ToAbsolute("api/haircut/createpayment/"+id); ViewBag.CreatePaymentUrl = Request.ToAbsolute("api/haircut/createpayment/" + id);
ViewBag.ExecutePaymentUrl = Request.ToAbsolute("api/payment/execute"); ViewBag.ExecutePaymentUrl = Request.ToAbsolute("api/payment/execute");
ViewBag.Urls=Request.GetPaymentUrls("HairCutCommand",id.ToString()); ViewBag.Urls = Request.GetPaymentUrls("HairCutCommand", id.ToString());
} }
public async Task<IActionResult> ClientCancelConfirm(long id) public async Task<IActionResult> ClientCancelConfirm(long id)
{ {
var query = await GetQuery(id);if (query == null) var query = await GetQuery(id); if (query == null)
{ {
return HttpNotFound(); return HttpNotFound();
} }
var uid = User.GetUserId(); var uid = User.GetUserId();
if (query.ClientId!=uid) if (query.ClientId != uid)
return new ChallengeResult(); return new ChallengeResult();
_context.HairCutQueries.Remove(query); _context.HairCutQueries.Remove(query);
await _context.SaveChangesAsync(); await _context.SaveChangesAsync();
@ -189,7 +192,7 @@ Le client final: {clientFinal}
.Include(x => x.PerformerProfile) .Include(x => x.PerformerProfile)
.Include(x => x.PerformerProfile.Performer) .Include(x => x.PerformerProfile.Performer)
.Include(x => x.Location) .Include(x => x.Location)
.Where(x=> x.ClientId == uid || x.PerformerId == uid) .Where(x => x.ClientId == uid || x.PerformerId == uid)
.ToListAsync()); .ToListAsync());
} }
@ -229,55 +232,63 @@ Le client final: {clientFinal}
long[] longtaintIds = null; long[] longtaintIds = null;
List<HairTaint> colors = null; List<HairTaint> colors = null;
if (taintIds!=null) {
longtaintIds = taintIds.Split(',').Select(s=>long.Parse(s)).ToArray();
colors = _context.HairTaint.Where(t=> longtaintIds.Contains(t.Id)).ToList();
// a Prestation is required
model.Prestation.Taints = colors.Select(c =>
new HairTaintInstance { Taint = c }).ToList();
}
if (string.IsNullOrWhiteSpace(uid) if (string.IsNullOrWhiteSpace(uid)
|| string.IsNullOrWhiteSpace(prid)) || string.IsNullOrWhiteSpace(prid))
throw new InvalidOperationException( throw new InvalidOperationException(
"This method needs a PerformerId" "This method needs a PerformerId"
); );
var pro = _context.Performers.Include(
u => u.Performer
).Include(u => u.Performer.Devices)
.FirstOrDefault(
x => x.PerformerId == model.PerformerId
);
model.PerformerProfile = pro;
if (!model.Consent) if (!model.Consent)
ModelState.AddModelError("Consent", "Vous devez accepter les conditions générales de vente de ce service"); ModelState.AddModelError("Consent", "Vous devez accepter les conditions générales de vente de ce service");
if (ModelState.IsValid) if (ModelState.IsValid)
{
var pro = _context.Performers.Include(
u => u.Performer
).Include(u => u.Performer.Devices)
.FirstOrDefault(
x => x.PerformerId == model.PerformerId
);
using (var trans = _context.Database.BeginTransaction())
{ {
using (var trans = _context.Database.BeginTransaction()) { if (taintIds != null)
// Une prestation pour enfant ou homme inclut toujours la coupe. {
longtaintIds = taintIds.Split(',').Select(s => long.Parse(s)).ToArray();
colors = _context.HairTaint.Where(t => longtaintIds.Contains(t.Id)).ToList();
// a Prestation is required
model.Prestation.Taints = colors.Select(c =>
new HairTaintInstance { Taint = c }).ToList();
}
// Une prestation pour enfant ou homme inclut toujours la coupe.
if (model.Prestation.Gender != HairCutGenders.Women) if (model.Prestation.Gender != HairCutGenders.Women)
model.Prestation.Cut = true; model.Prestation.Cut = true;
if (model.Location!=null) { if (model.Location != null)
var existingLocation = await _context.Locations.FirstOrDefaultAsync( x=>x.Address == model.Location.Address {
&& x.Longitude == model.Location.Longitude && x.Latitude == model.Location.Latitude ); var existingLocation = await _context.Locations.FirstOrDefaultAsync(x => x.Address == model.Location.Address
&& x.Longitude == model.Location.Longitude && x.Latitude == model.Location.Latitude);
if (existingLocation!=null) {
model.Location=existingLocation; if (existingLocation != null)
{
model.Location = existingLocation;
} }
else _context.Attach<Location>(model.Location); else _context.Attach<Location>(model.Location);
} }
var existingPrestation = await _context.HairPrestation.FirstOrDefaultAsync( x=> model.PrestationId == x.Id ); var existingPrestation = await _context.HairPrestation.FirstOrDefaultAsync(x => model.PrestationId == x.Id);
if (existingPrestation!=null) { if (existingPrestation != null)
{
model.Prestation = existingPrestation; model.Prestation = existingPrestation;
} }
else _context.Attach<HairPrestation>(model.Prestation); else _context.Attach<HairPrestation>(model.Prestation);
_context.HairCutQueries.Add(model); _context.HairCutQueries.Add(model);
var brusherProfile = await _context.BrusherProfile.SingleAsync(p=>p.UserId == pro.PerformerId); var brusherProfile = await _context.BrusherProfile.SingleAsync(p => p.UserId == pro.PerformerId);
model.Client = await _context.Users.SingleAsync(u=>u.Id == model.ClientId); model.Client = await _context.Users.SingleAsync(u => u.Id == model.ClientId);
model.SelectedProfile = brusherProfile; model.SelectedProfile = brusherProfile;
await _context.SaveChangesAsync(uid); await _context.SaveChangesAsync(uid);
@ -290,23 +301,25 @@ Le client final: {clientFinal}
if (pro.AcceptPublicContact) if (pro.AcceptPublicContact)
{ {
if (pro.AcceptNotifications) { if (pro.AcceptNotifications)
if (pro.Performer.Devices.Count > 0) { {
var regids = model.PerformerProfile.Performer if (pro.Performer.Devices.Count > 0)
.Devices.Select(d => d.GCMRegistrationId); {
grep = await _GCMSender.NotifyHairCutQueryAsync(_googleSettings,regids,yaev); var regids = pro.Performer.Devices.Select(d => d.GCMRegistrationId);
grep = await _GCMSender.NotifyHairCutQueryAsync(_googleSettings, regids, yaev);
} }
// 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;
if (grep!=null) if (grep != null)
_logger.LogWarning($"Performer: {model.PerformerProfile.Performer.UserName} success: {grep.success} failure: {grep.failure}"); _logger.LogWarning($"Performer: {pro.Performer.UserName} success: {grep.success} failure: {grep.failure}");
} }
// TODO if pro.AllowCalendarEventInsert // TODO if pro.AllowCalendarEventInsert
if (pro.Performer.DedicatedGoogleCalendar != null && yaev.EventDate != null) { if (pro.Performer.DedicatedGoogleCalendar != null && yaev.EventDate != null)
{
_logger.LogInformation("Inserting an event in the calendar"); _logger.LogInformation("Inserting an event in the calendar");
DateTime evdate = yaev.EventDate ?? new DateTime(); DateTime evdate = yaev.EventDate ?? new DateTime();
var result = await _calendarManager.CreateEventAsync(pro.Performer.Id, var result = await _calendarManager.CreateEventAsync(pro.Performer.Id,
pro.Performer.DedicatedGoogleCalendar, pro.Performer.DedicatedGoogleCalendar,
evdate, 3600, yaev.Topic, yaev.Message, evdate, 3600, yaev.Topic, yaev.Message,
@ -319,48 +332,52 @@ Le client final: {clientFinal}
await _emailSender.SendEmailAsync( await _emailSender.SendEmailAsync(
_siteSettings, _smtpSettings, _siteSettings, _smtpSettings,
model.PerformerProfile.Performer.Email, pro.Performer.Email,
yaev.Reason, yaev.Reason,
$"{yaev.Message}\r\n-- \r\n{yaev.Previsional}\r\n{yaev.EventDate}\r\n" $"{yaev.Message}\r\n-- \r\n{yaev.Previsional}\r\n{yaev.EventDate}\r\n"
); );
} }
else { else
{
// TODO if (AcceptProContact) try & find a bookmaker to send him this query // TODO if (AcceptProContact) try & find a bookmaker to send him this query
} }
ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == model.ActivityCode); ViewBag.Activity = _context.Activities.FirstOrDefault(a => a.Code == model.ActivityCode);
ViewBag.GoogleSettings = _googleSettings; ViewBag.GoogleSettings = _googleSettings;
var items = model.GetBillItems(); var items = model.GetBillItems();
var addition = items.Addition(); var addition = items.Addition();
ViewBag.Addition = addition.ToString("C",CultureInfo.CurrentUICulture); ViewBag.Addition = addition.ToString("C", CultureInfo.CurrentUICulture);
return View("CommandConfirmation",model); return View("CommandConfirmation", model);
} }
ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == model.ActivityCode); ViewBag.Activity = _context.Activities.FirstOrDefault(a => a.Code == model.ActivityCode);
ViewBag.GoogleSettings = _googleSettings; ViewBag.GoogleSettings = _googleSettings;
SetViewData(model.ActivityCode,model.PerformerId,model.Prestation); SetViewData(model.ActivityCode, model.PerformerId, model.Prestation);
return View("HairCut",model); return View("HairCut", model);
} }
public async Task<ActionResult> HairCut(string performerId, string activityCode) public async Task<ActionResult> HairCut(string performerId, string activityCode)
{ {
HairPrestation pPrestation=null; HairPrestation pPrestation = null;
var prestaJson = HttpContext.Session.GetString("HairCutPresta") ; var prestaJson = HttpContext.Session.GetString("HairCutPresta");
if (prestaJson!=null) { if (prestaJson != null)
{
pPrestation = JsonConvert.DeserializeObject<HairPrestation>(prestaJson); pPrestation = JsonConvert.DeserializeObject<HairPrestation>(prestaJson);
} }
else { else
pPrestation = new HairPrestation {}; {
pPrestation = new HairPrestation { };
} }
var uid = User.GetUserId(); var uid = User.GetUserId();
var user = await _userManager.FindByIdAsync(uid); var user = await _userManager.FindByIdAsync(uid);
SetViewData(activityCode,performerId,pPrestation); SetViewData(activityCode, performerId, pPrestation);
var perfer = _context.Performers.Include( var perfer = _context.Performers.Include(
p=>p.Performer p => p.Performer
).Single(p=>p.PerformerId == performerId); ).Single(p => p.PerformerId == performerId);
var result = new HairCutQuery { var result = new HairCutQuery
{
PerformerProfile = perfer, PerformerProfile = perfer,
PerformerId = perfer.PerformerId, PerformerId = perfer.PerformerId,
ClientId = uid, ClientId = uid,
@ -371,25 +388,26 @@ Le client final: {clientFinal}
}; };
return View(result); return View(result);
} }
private void SetViewData (string activityCode, string performerId, HairPrestation pPrestation ) private void SetViewData(string activityCode, string performerId, HairPrestation pPrestation)
{ {
ViewBag.HairTaints = _context.HairTaint.Include(t=>t.Color); ViewBag.HairTaints = _context.HairTaint.Include(t => t.Color);
ViewBag.HairTaintsItems = _context.HairTaint.Include(t=>t.Color).Select( ViewBag.HairTaintsItems = _context.HairTaint.Include(t => t.Color).Select(
c=> c =>
new SelectListItem { new SelectListItem
Text = c.Color.Name+" "+c.Brand, {
Text = c.Color.Name + " " + c.Brand,
Value = c.Id.ToString() Value = c.Id.ToString()
} }
); );
ViewBag.HairTechnos = EnumExtensions.GetSelectList(typeof(HairTechnos),_localizer); ViewBag.HairTechnos = EnumExtensions.GetSelectList(typeof(HairTechnos), _localizer);
ViewBag.HairLength = EnumExtensions.GetSelectList(typeof(HairLength),_localizer); ViewBag.HairLength = EnumExtensions.GetSelectList(typeof(HairLength), _localizer);
ViewBag.Activity = _context.Activities.First(a => a.Code == activityCode); ViewBag.Activity = _context.Activities.First(a => a.Code == activityCode);
ViewBag.Gender = EnumExtensions.GetSelectList(typeof(HairCutGenders),_localizer,HairCutGenders.Women); ViewBag.Gender = EnumExtensions.GetSelectList(typeof(HairCutGenders), _localizer, HairCutGenders.Women);
ViewBag.HairDressings = EnumExtensions.GetSelectList(typeof(HairDressings),_localizer); ViewBag.HairDressings = EnumExtensions.GetSelectList(typeof(HairDressings), _localizer);
ViewBag.ColorsClass = ( pPrestation.Tech == HairTechnos.Color ViewBag.ColorsClass = (pPrestation.Tech == HairTechnos.Color
|| pPrestation.Tech == HairTechnos.Mech ) ? "":"hidden"; || pPrestation.Tech == HairTechnos.Mech) ? "" : "hidden";
ViewBag.TechClass = ( pPrestation.Gender == HairCutGenders.Women ) ? "":"hidden"; ViewBag.TechClass = (pPrestation.Gender == HairCutGenders.Women) ? "" : "hidden";
ViewData["PerfPrefs"] = _context.BrusherProfile.Single(p=>p.UserId == performerId); ViewData["PerfPrefs"] = _context.BrusherProfile.Single(p => p.UserId == performerId);
} }
[HttpPost, Authorize] [HttpPost, Authorize]
@ -420,41 +438,44 @@ Le client final: {clientFinal}
ModelState.MarkFieldSkipped("ClientId"); ModelState.MarkFieldSkipped("ClientId");
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
var existingLocation = _context.Locations.FirstOrDefault( x=>x.Address == command.Location.Address var existingLocation = _context.Locations.FirstOrDefault(x => x.Address == command.Location.Address
&& x.Longitude == command.Location.Longitude && x.Latitude == command.Location.Latitude ); && x.Longitude == command.Location.Longitude && x.Latitude == command.Location.Latitude);
if (existingLocation!=null) { if (existingLocation != null)
command.Location=existingLocation; {
command.Location = existingLocation;
} }
else _context.Attach<Location>(command.Location); else _context.Attach<Location>(command.Location);
_context.HairMultiCutQueries.Add(command, GraphBehavior.IncludeDependents); _context.HairMultiCutQueries.Add(command, GraphBehavior.IncludeDependents);
_context.SaveChanges(User.GetUserId()); _context.SaveChanges(User.GetUserId());
var brSettings = await _context.BrusherProfile.SingleAsync( var brSettings = await _context.BrusherProfile.SingleAsync(
bp=>bp.UserId == command.PerformerId bp => bp.UserId == command.PerformerId
); );
var yaev = command.CreateEvent(_localizer,brSettings); var yaev = command.CreateEvent(_localizer, brSettings);
MessageWithPayloadResponse grep = null; MessageWithPayloadResponse grep = null;
if (pro.AcceptNotifications if (pro.AcceptNotifications
&& pro.AcceptPublicContact) && pro.AcceptPublicContact)
{ {
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.NotifyHairCutQueryAsync(_googleSettings,regids,yaev); grep = await _GCMSender.NotifyHairCutQueryAsync(_googleSettings, regids, yaev);
} }
// TODO setup a profile choice to allow notifications // TODO setup a profile choice to allow notifications
// both on mailbox and mobile, and to allow calendar event insertion. // both on mailbox and mobile, and to allow calendar event insertion.
// if (grep==null || grep.success<=0 || grep.failure>0) // if (grep==null || grep.success<=0 || grep.failure>0)
ViewBag.GooglePayload=grep; ViewBag.GooglePayload = grep;
if (grep!=null) if (grep != null)
_logger.LogWarning($"Performer: {command.PerformerProfile.Performer.UserName} success: {grep.success} failure: {grep.failure}"); _logger.LogWarning($"Performer: {command.PerformerProfile.Performer.UserName} success: {grep.success} failure: {grep.failure}");
if (pro.Performer.DedicatedGoogleCalendar != null && yaev.EventDate != null) { if (pro.Performer.DedicatedGoogleCalendar != null && yaev.EventDate != null)
DateTime evdate = yaev.EventDate ?? new DateTime(); {
DateTime evdate = yaev.EventDate ?? new DateTime();
await _calendarManager.CreateEventAsync( await _calendarManager.CreateEventAsync(
pro.Performer.Id, pro.Performer.Id,
pro.Performer.DedicatedGoogleCalendar, pro.Performer.DedicatedGoogleCalendar,
@ -466,17 +487,17 @@ Le client final: {clientFinal}
await _emailSender.SendEmailAsync( await _emailSender.SendEmailAsync(
_siteSettings, _smtpSettings, _siteSettings, _smtpSettings,
command.PerformerProfile.Performer.Email, command.PerformerProfile.Performer.Email,
yaev.Topic+" "+yaev.Sender, yaev.Topic + " " + yaev.Sender,
$"{yaev.Message}\r\n-- \r\n{yaev.Previsional}\r\n{yaev.EventDate}\r\n" $"{yaev.Message}\r\n-- \r\n{yaev.Previsional}\r\n{yaev.EventDate}\r\n"
); );
} }
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;
return View("CommandConfirmation",command); return View("CommandConfirmation", command);
} }
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;
return View("HairCut",command); return View("HairCut", command);
} }
} }
} }

@ -14,6 +14,7 @@ namespace Yavsc
ValueProviderResult valueResult = bindingContext.ValueProvider ValueProviderResult valueResult = bindingContext.ValueProvider
.GetValue(bindingContext.ModelName); .GetValue(bindingContext.ModelName);
decimal actualValue ; decimal actualValue ;
try { try {
actualValue = Decimal.Parse(valueResult.FirstValue, System.Globalization.NumberStyles.AllowDecimalPoint); actualValue = Decimal.Parse(valueResult.FirstValue, System.Globalization.NumberStyles.AllowDecimalPoint);
return await ModelBindingResult.SuccessAsync(bindingContext.ModelName,actualValue); return await ModelBindingResult.SuccessAsync(bindingContext.ModelName,actualValue);
@ -32,7 +33,7 @@ namespace Yavsc
.GetValue(bindingContext.ModelName); .GetValue(bindingContext.ModelName);
DateTime actualValue ; DateTime actualValue ;
ModelStateEntry modelState = new ModelStateEntry(); ModelStateEntry modelState = new ModelStateEntry();
// DateTime are sent in the french format
if (DateTime.TryParse(valueResult.FirstValue,new CultureInfo("fr-FR"), DateTimeStyles.AllowInnerWhite, out actualValue)) if (DateTime.TryParse(valueResult.FirstValue,new CultureInfo("fr-FR"), DateTimeStyles.AllowInnerWhite, out actualValue))
{ {
return await ModelBindingResult.SuccessAsync(bindingContext.ModelName,actualValue); return await ModelBindingResult.SuccessAsync(bindingContext.ModelName,actualValue);

@ -132,6 +132,7 @@ namespace Yavsc
options.RequestCultureProviders.Insert(0, new AcceptLanguageHeaderRequestCultureProvider()); options.RequestCultureProviders.Insert(0, new AcceptLanguageHeaderRequestCultureProvider());
options.RequestCultureProviders.Insert(0, new CookieRequestCultureProvider()); options.RequestCultureProviders.Insert(0, new CookieRequestCultureProvider());
}); });
@ -205,8 +206,8 @@ namespace Yavsc
.Build(); .Build();
config.Filters.Add(new AuthorizeFilter(policy)); config.Filters.Add(new AuthorizeFilter(policy));
config.Filters.Add(new ProducesAttribute("application/json")); config.Filters.Add(new ProducesAttribute("application/json"));
config.ModelBinders.Add(new MyDateTimeModelBinder()); // config.ModelBinders.Insert(0,new MyDateTimeModelBinder());
config.ModelBinders.Add(new MyDecimalModelBinder()); // config.ModelBinders.Insert(0,new MyDecimalModelBinder());
config.OutputFormatters.Add(new PdfFormatter()); config.OutputFormatters.Add(new PdfFormatter());
}).AddFormatterMappings( }).AddFormatterMappings(
@ -357,7 +358,7 @@ namespace Yavsc
ConfigureFileServerApp(app, SiteSetup, env, authorizationService); ConfigureFileServerApp(app, SiteSetup, env, authorizationService);
ConfigureWebSocketsApp(app, SiteSetup, env); ConfigureWebSocketsApp(app, SiteSetup, env);
ConfigureWorkflow(app, SiteSetup, logger); ConfigureWorkflow(app, SiteSetup, logger);
app.UseRequestLocalization(localizationOptions.Value, (RequestCulture) new RequestCulture((string)"fr")); app.UseRequestLocalization(localizationOptions.Value, (RequestCulture) new RequestCulture((string)"en-US"));
app.UseSession(); app.UseSession();
app.UseMvc(routes => app.UseMvc(routes =>

@ -1,4 +1,5 @@
@model BrusherProfile @model BrusherProfile
<script> <script>
var tarifs = var tarifs =
[ [

@ -39,7 +39,6 @@
<environment names="Development,coiffure"> <environment names="Development,coiffure">
<!-- Custom Fonts --> <!-- Custom Fonts -->
<link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css">
<style> <style>

Loading…