input filters
This commit is contained in:
@ -254,30 +254,36 @@ Le client final: {clientFinal}
|
|||||||
|
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
// Une prestation pour enfant ou homme inclut toujours la coupe.
|
|
||||||
if (model.Prestation.Gender != HairCutGenders.Women)
|
|
||||||
model.Prestation.Cut = true;
|
|
||||||
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) {
|
using (var trans = _context.Database.BeginTransaction()) {
|
||||||
model.Location=existingLocation;
|
// Une prestation pour enfant ou homme inclut toujours la coupe.
|
||||||
|
if (model.Prestation.Gender != HairCutGenders.Women)
|
||||||
|
model.Prestation.Cut = true;
|
||||||
|
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) {
|
||||||
|
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);
|
||||||
|
var brusherProfile = await _context.BrusherProfile.SingleAsync(p=>p.UserId == pro.PerformerId);
|
||||||
|
model.Client = await _context.Users.SingleAsync(u=>u.Id == model.ClientId);
|
||||||
|
model.SelectedProfile = brusherProfile;
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync(uid);
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
|
||||||
_context.HairCutQueries.Add(model);
|
|
||||||
var brusherProfile = await _context.BrusherProfile.SingleAsync(p=>p.UserId == pro.PerformerId);
|
|
||||||
model.Client = await _context.Users.SingleAsync(u=>u.Id == model.ClientId);
|
|
||||||
model.SelectedProfile = brusherProfile;
|
|
||||||
await _context.SaveChangesAsync(uid);
|
|
||||||
var yaev = model.CreateNewHairCutQueryEvent(_localizer);
|
var yaev = model.CreateNewHairCutQueryEvent(_localizer);
|
||||||
MessageWithPayloadResponse grep = null;
|
MessageWithPayloadResponse grep = null;
|
||||||
|
|
||||||
@ -326,7 +332,6 @@ Le client final: {clientFinal}
|
|||||||
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);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Yavsc
|
namespace Yavsc
|
||||||
{
|
{
|
||||||
@ -9,13 +11,12 @@ namespace Yavsc
|
|||||||
|
|
||||||
public async Task<ModelBindingResult> BindModelAsync(ModelBindingContext bindingContext)
|
public async Task<ModelBindingResult> BindModelAsync(ModelBindingContext bindingContext)
|
||||||
{
|
{
|
||||||
ValueProviderResult valueResult = bindingContext.ValueProvider
|
Console.WriteLine(JsonConvert.SerializeObject(bindingContext));
|
||||||
|
ValueProviderResult valueResult = bindingContext.ValueProvider
|
||||||
.GetValue(bindingContext.ModelName);
|
.GetValue(bindingContext.ModelName);
|
||||||
decimal actualValue ;
|
decimal actualValue ;
|
||||||
ModelStateEntry modelState = new ModelStateEntry();
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
catch (Exception ) {
|
catch (Exception ) {
|
||||||
@ -23,4 +24,28 @@ namespace Yavsc
|
|||||||
return await ModelBindingResult.FailedAsync(bindingContext.ModelName);
|
return await ModelBindingResult.FailedAsync(bindingContext.ModelName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class MyDateTimeModelBinder : IModelBinder
|
||||||
|
{
|
||||||
|
public async Task<ModelBindingResult> BindModelAsync(ModelBindingContext bindingContext)
|
||||||
|
{
|
||||||
|
Console.WriteLine(JsonConvert.SerializeObject(bindingContext.ValueProvider));
|
||||||
|
ValueProviderResult valueResult = bindingContext.ValueProvider
|
||||||
|
.GetValue(bindingContext.ModelName);
|
||||||
|
Console.WriteLine(JsonConvert.SerializeObject(valueResult));
|
||||||
|
DateTime actualValue ;
|
||||||
|
ModelStateEntry modelState = new ModelStateEntry();
|
||||||
|
CultureInfo[] cultures = { new CultureInfo("en-US"),
|
||||||
|
new CultureInfo("fr-FR"),
|
||||||
|
new CultureInfo("it-IT"),
|
||||||
|
new CultureInfo("de-DE") };
|
||||||
|
foreach (CultureInfo culture in cultures)
|
||||||
|
if (DateTime.TryParse(valueResult.FirstValue,culture, DateTimeStyles.AllowInnerWhite, out actualValue))
|
||||||
|
{
|
||||||
|
return await ModelBindingResult.SuccessAsync(bindingContext.ModelName,actualValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await ModelBindingResult.FailedAsync(bindingContext.ModelName);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -36,7 +36,6 @@ namespace Yavsc.Services
|
|||||||
{
|
{
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Google.Apis.Auth.OAuth2.Flows;
|
using Google.Apis.Auth.OAuth2.Flows;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Yavsc.Helpers;
|
using Yavsc.Helpers;
|
||||||
using Yavsc.Models;
|
using Yavsc.Models;
|
||||||
using Yavsc.Models.Calendar;
|
using Yavsc.Models.Calendar;
|
||||||
@ -79,7 +78,6 @@ namespace Yavsc.Services
|
|||||||
Scopes = new[] { scopeCalendar },
|
Scopes = new[] { scopeCalendar },
|
||||||
DataStore = dataStore
|
DataStore = dataStore
|
||||||
});
|
});
|
||||||
_logger.LogWarning($"Using Google data store from "+JsonConvert.SerializeObject(_dataStore));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -205,6 +205,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.Add(new MyDecimalModelBinder());
|
||||||
config.OutputFormatters.Add(new PdfFormatter());
|
config.OutputFormatters.Add(new PdfFormatter());
|
||||||
|
|
||||||
}).AddFormatterMappings(
|
}).AddFormatterMappings(
|
||||||
@ -245,6 +247,7 @@ namespace Yavsc
|
|||||||
|
|
||||||
|
|
||||||
public static IStringLocalizer GlobalLocalizer { get; private set; }
|
public static IStringLocalizer GlobalLocalizer { get; private set; }
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env,
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env,
|
||||||
IOptions<SiteSettings> siteSettings,
|
IOptions<SiteSettings> siteSettings,
|
||||||
@ -338,6 +341,7 @@ namespace Yavsc
|
|||||||
else throw ex;
|
else throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// before fixing the security protocol, let beleive our lib it's done with it.
|
// before fixing the security protocol, let beleive our lib it's done with it.
|
||||||
var cxmgr = ConnectionManager.Instance;
|
var cxmgr = ConnectionManager.Instance;
|
||||||
// then, fix it.
|
// then, fix it.
|
||||||
@ -361,6 +365,7 @@ namespace Yavsc
|
|||||||
routes.MapRoute(
|
routes.MapRoute(
|
||||||
name: "default",
|
name: "default",
|
||||||
template: "{controller=Home}/{action=Index}/{id?}");
|
template: "{controller=Home}/{action=Index}/{id?}");
|
||||||
|
|
||||||
});
|
});
|
||||||
logger.LogInformation("LocalApplicationData: "+Environment.GetFolderPath(SpecialFolder.LocalApplicationData, SpecialFolderOption.DoNotVerify));
|
logger.LogInformation("LocalApplicationData: "+Environment.GetFolderPath(SpecialFolder.LocalApplicationData, SpecialFolderOption.DoNotVerify));
|
||||||
|
|
||||||
|
@ -181,8 +181,8 @@
|
|||||||
var pos = loc.geometry.location;
|
var pos = loc.geometry.location;
|
||||||
var lat = new Number(pos.lat);
|
var lat = new Number(pos.lat);
|
||||||
var lng = new Number(pos.lng);
|
var lng = new Number(pos.lng);
|
||||||
$('#' + config.latId).val(lat);
|
$('#' + config.latId).val(lat.toLocaleString('en'));
|
||||||
$('#' + config.longId).val(lng);
|
$('#' + config.longId).val(lng.toLocaleString('en'));
|
||||||
gmap.setCenter(pos);
|
gmap.setCenter(pos);
|
||||||
if (marker) {
|
if (marker) {
|
||||||
marker.setMap(null);
|
marker.setMap(null);
|
||||||
@ -196,8 +196,8 @@
|
|||||||
google.maps.event.addListener(marker, 'dragend', function () {
|
google.maps.event.addListener(marker, 'dragend', function () {
|
||||||
// TODO reverse geo code
|
// TODO reverse geo code
|
||||||
var pos = marker.getPosition();
|
var pos = marker.getPosition();
|
||||||
$('#' + config.latId).val(pos.lat);
|
$('#' + config.latId).val(pos.lat.toLocaleString('en'));
|
||||||
$('#' + config.longId).val(pos.lng);
|
$('#' + config.longId).val(pos.lng.toLocaleString('en'));
|
||||||
});
|
});
|
||||||
$('#' + config.addrId).valid();
|
$('#' + config.addrId).valid();
|
||||||
$('#' + config.addrValidationId).empty();
|
$('#' + config.addrValidationId).empty();
|
||||||
|
Reference in New Issue
Block a user