restores the legacy behavior
This commit is contained in:
parent
61f2b79048
commit
2f7d5a4b2e
5 changed files with 175 additions and 152 deletions
|
|
@ -126,8 +126,10 @@ Le client final: {clientFinal}
|
|||
|
||||
");
|
||||
|
||||
if (command.PerformerProfile.AcceptNotifications) {
|
||||
if (command.PerformerProfile.Performer.Devices.Count > 0) {
|
||||
if (command.PerformerProfile.AcceptNotifications)
|
||||
{
|
||||
if (command.PerformerProfile.Performer.Devices.Count > 0)
|
||||
{
|
||||
var regids = command.PerformerProfile.Performer
|
||||
.Devices.Select(d => d.GCMRegistrationId);
|
||||
grep = await _GCMSender.NotifyHairCutQueryAsync(_googleSettings, regids, yaev);
|
||||
|
|
@ -145,7 +147,8 @@ Le client final: {clientFinal}
|
|||
$"{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
|
||||
}
|
||||
|
||||
|
|
@ -189,7 +192,7 @@ Le client final: {clientFinal}
|
|||
.Include(x => x.PerformerProfile)
|
||||
.Include(x => x.PerformerProfile.Performer)
|
||||
.Include(x => x.Location)
|
||||
.Where(x=> x.ClientId == uid || x.PerformerId == uid)
|
||||
.Where(x => x.ClientId == uid || x.PerformerId == uid)
|
||||
.ToListAsync());
|
||||
}
|
||||
|
||||
|
|
@ -229,48 +232,56 @@ Le client final: {clientFinal}
|
|||
long[] longtaintIds = 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)
|
||||
|| string.IsNullOrWhiteSpace(prid))
|
||||
throw new InvalidOperationException(
|
||||
"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)
|
||||
ModelState.AddModelError("Consent", "Vous devez accepter les conditions générales de vente de ce service");
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
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);
|
||||
|
||||
if (existingLocation!=null) {
|
||||
if (existingLocation != null)
|
||||
{
|
||||
model.Location = existingLocation;
|
||||
}
|
||||
else _context.Attach<Location>(model.Location);
|
||||
}
|
||||
var existingPrestation = await _context.HairPrestation.FirstOrDefaultAsync(x => model.PrestationId == x.Id);
|
||||
|
||||
if (existingPrestation!=null) {
|
||||
if (existingPrestation != null)
|
||||
{
|
||||
model.Prestation = existingPrestation;
|
||||
}
|
||||
else _context.Attach<HairPrestation>(model.Prestation);
|
||||
|
|
@ -290,10 +301,11 @@ Le client final: {clientFinal}
|
|||
if (pro.AcceptPublicContact)
|
||||
{
|
||||
|
||||
if (pro.AcceptNotifications) {
|
||||
if (pro.Performer.Devices.Count > 0) {
|
||||
var regids = model.PerformerProfile.Performer
|
||||
.Devices.Select(d => d.GCMRegistrationId);
|
||||
if (pro.AcceptNotifications)
|
||||
{
|
||||
if (pro.Performer.Devices.Count > 0)
|
||||
{
|
||||
var regids = pro.Performer.Devices.Select(d => d.GCMRegistrationId);
|
||||
grep = await _GCMSender.NotifyHairCutQueryAsync(_googleSettings, regids, yaev);
|
||||
}
|
||||
// TODO setup a profile choice to allow notifications
|
||||
|
|
@ -301,10 +313,11 @@ Le client final: {clientFinal}
|
|||
// if (grep==null || grep.success<=0 || grep.failure>0)
|
||||
ViewBag.GooglePayload = grep;
|
||||
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
|
||||
if (pro.Performer.DedicatedGoogleCalendar != null && yaev.EventDate != null) {
|
||||
if (pro.Performer.DedicatedGoogleCalendar != null && yaev.EventDate != null)
|
||||
{
|
||||
_logger.LogInformation("Inserting an event in the calendar");
|
||||
DateTime evdate = yaev.EventDate ?? new DateTime();
|
||||
var result = await _calendarManager.CreateEventAsync(pro.Performer.Id,
|
||||
|
|
@ -319,12 +332,13 @@ Le client final: {clientFinal}
|
|||
|
||||
await _emailSender.SendEmailAsync(
|
||||
_siteSettings, _smtpSettings,
|
||||
model.PerformerProfile.Performer.Email,
|
||||
pro.Performer.Email,
|
||||
yaev.Reason,
|
||||
$"{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
|
||||
}
|
||||
ViewBag.Activity = _context.Activities.FirstOrDefault(a => a.Code == model.ActivityCode);
|
||||
|
|
@ -345,10 +359,12 @@ Le client final: {clientFinal}
|
|||
{
|
||||
HairPrestation pPrestation = null;
|
||||
var prestaJson = HttpContext.Session.GetString("HairCutPresta");
|
||||
if (prestaJson!=null) {
|
||||
if (prestaJson != null)
|
||||
{
|
||||
pPrestation = JsonConvert.DeserializeObject<HairPrestation>(prestaJson);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
pPrestation = new HairPrestation { };
|
||||
}
|
||||
|
||||
|
|
@ -360,7 +376,8 @@ Le client final: {clientFinal}
|
|||
var perfer = _context.Performers.Include(
|
||||
p => p.Performer
|
||||
).Single(p => p.PerformerId == performerId);
|
||||
var result = new HairCutQuery {
|
||||
var result = new HairCutQuery
|
||||
{
|
||||
PerformerProfile = perfer,
|
||||
PerformerId = perfer.PerformerId,
|
||||
ClientId = uid,
|
||||
|
|
@ -376,7 +393,8 @@ Le client final: {clientFinal}
|
|||
ViewBag.HairTaints = _context.HairTaint.Include(t => t.Color);
|
||||
ViewBag.HairTaintsItems = _context.HairTaint.Include(t => t.Color).Select(
|
||||
c =>
|
||||
new SelectListItem {
|
||||
new SelectListItem
|
||||
{
|
||||
Text = c.Color.Name + " " + c.Brand,
|
||||
Value = c.Id.ToString()
|
||||
}
|
||||
|
|
@ -424,7 +442,8 @@ Le client final: {clientFinal}
|
|||
var existingLocation = _context.Locations.FirstOrDefault(x => x.Address == command.Location.Address
|
||||
&& x.Longitude == command.Location.Longitude && x.Latitude == command.Location.Latitude);
|
||||
|
||||
if (existingLocation!=null) {
|
||||
if (existingLocation != null)
|
||||
{
|
||||
command.Location = existingLocation;
|
||||
}
|
||||
else _context.Attach<Location>(command.Location);
|
||||
|
|
@ -440,7 +459,8 @@ Le client final: {clientFinal}
|
|||
if (pro.AcceptNotifications
|
||||
&& pro.AcceptPublicContact)
|
||||
{
|
||||
if (pro.Performer.Devices?.Count > 0) {
|
||||
if (pro.Performer.Devices?.Count > 0)
|
||||
{
|
||||
var regids = command.PerformerProfile.Performer
|
||||
.Devices.Select(d => d.GCMRegistrationId);
|
||||
grep = await _GCMSender.NotifyHairCutQueryAsync(_googleSettings, regids, yaev);
|
||||
|
|
@ -453,7 +473,8 @@ Le client final: {clientFinal}
|
|||
_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();
|
||||
await _calendarManager.CreateEventAsync(
|
||||
pro.Performer.Id,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ namespace Yavsc
|
|||
ValueProviderResult valueResult = bindingContext.ValueProvider
|
||||
.GetValue(bindingContext.ModelName);
|
||||
decimal actualValue ;
|
||||
|
||||
try {
|
||||
actualValue = Decimal.Parse(valueResult.FirstValue, System.Globalization.NumberStyles.AllowDecimalPoint);
|
||||
return await ModelBindingResult.SuccessAsync(bindingContext.ModelName,actualValue);
|
||||
|
|
@ -32,7 +33,7 @@ namespace Yavsc
|
|||
.GetValue(bindingContext.ModelName);
|
||||
DateTime actualValue ;
|
||||
ModelStateEntry modelState = new ModelStateEntry();
|
||||
|
||||
// DateTime are sent in the french format
|
||||
if (DateTime.TryParse(valueResult.FirstValue,new CultureInfo("fr-FR"), DateTimeStyles.AllowInnerWhite, out 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 CookieRequestCultureProvider());
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -205,8 +206,8 @@ namespace Yavsc
|
|||
.Build();
|
||||
config.Filters.Add(new AuthorizeFilter(policy));
|
||||
config.Filters.Add(new ProducesAttribute("application/json"));
|
||||
config.ModelBinders.Add(new MyDateTimeModelBinder());
|
||||
config.ModelBinders.Add(new MyDecimalModelBinder());
|
||||
// config.ModelBinders.Insert(0,new MyDateTimeModelBinder());
|
||||
// config.ModelBinders.Insert(0,new MyDecimalModelBinder());
|
||||
config.OutputFormatters.Add(new PdfFormatter());
|
||||
|
||||
}).AddFormatterMappings(
|
||||
|
|
@ -357,7 +358,7 @@ namespace Yavsc
|
|||
ConfigureFileServerApp(app, SiteSetup, env, authorizationService);
|
||||
ConfigureWebSocketsApp(app, SiteSetup, env);
|
||||
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.UseMvc(routes =>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
@model BrusherProfile
|
||||
|
||||
<script>
|
||||
var tarifs =
|
||||
[
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@
|
|||
<environment names="Development,coiffure">
|
||||
|
||||
<!-- 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=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css">
|
||||
<style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue