input filters
This commit is contained in:
@ -254,30 +254,36 @@ Le client final: {clientFinal}
|
||||
|
||||
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) {
|
||||
model.Location=existingLocation;
|
||||
using (var trans = _context.Database.BeginTransaction()) {
|
||||
// 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) {
|
||||
model.Prestation = existingPrestation;
|
||||
}
|
||||
else _context.Attach<HairPrestation>(model.Prestation);
|
||||
if (existingPrestation!=null) {
|
||||
model.Prestation = existingPrestation;
|
||||
}
|
||||
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);
|
||||
MessageWithPayloadResponse grep = null;
|
||||
|
||||
@ -326,7 +332,6 @@ Le client final: {clientFinal}
|
||||
var items = model.GetBillItems();
|
||||
var addition = items.Addition();
|
||||
ViewBag.Addition = addition.ToString("C",CultureInfo.CurrentUICulture);
|
||||
|
||||
return View("CommandConfirmation",model);
|
||||
}
|
||||
ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == model.ActivityCode);
|
||||
|
@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
@ -9,13 +11,12 @@ namespace Yavsc
|
||||
|
||||
public async Task<ModelBindingResult> BindModelAsync(ModelBindingContext bindingContext)
|
||||
{
|
||||
ValueProviderResult valueResult = bindingContext.ValueProvider
|
||||
Console.WriteLine(JsonConvert.SerializeObject(bindingContext));
|
||||
ValueProviderResult valueResult = bindingContext.ValueProvider
|
||||
.GetValue(bindingContext.ModelName);
|
||||
decimal actualValue ;
|
||||
ModelStateEntry modelState = new ModelStateEntry();
|
||||
try {
|
||||
actualValue = Decimal.Parse(valueResult.FirstValue, System.Globalization.NumberStyles.AllowDecimalPoint);
|
||||
|
||||
return await ModelBindingResult.SuccessAsync(bindingContext.ModelName,actualValue);
|
||||
}
|
||||
catch (Exception ) {
|
||||
@ -23,4 +24,28 @@ namespace Yavsc
|
||||
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 Google.Apis.Auth.OAuth2.Flows;
|
||||
using Newtonsoft.Json;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Calendar;
|
||||
@ -79,7 +78,6 @@ namespace Yavsc.Services
|
||||
Scopes = new[] { scopeCalendar },
|
||||
DataStore = dataStore
|
||||
});
|
||||
_logger.LogWarning($"Using Google data store from "+JsonConvert.SerializeObject(_dataStore));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -205,6 +205,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.OutputFormatters.Add(new PdfFormatter());
|
||||
|
||||
}).AddFormatterMappings(
|
||||
@ -245,6 +247,7 @@ namespace Yavsc
|
||||
|
||||
|
||||
public static IStringLocalizer GlobalLocalizer { get; private set; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env,
|
||||
IOptions<SiteSettings> siteSettings,
|
||||
@ -338,6 +341,7 @@ namespace Yavsc
|
||||
else throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
// before fixing the security protocol, let beleive our lib it's done with it.
|
||||
var cxmgr = ConnectionManager.Instance;
|
||||
// then, fix it.
|
||||
@ -361,6 +365,7 @@ namespace Yavsc
|
||||
routes.MapRoute(
|
||||
name: "default",
|
||||
template: "{controller=Home}/{action=Index}/{id?}");
|
||||
|
||||
});
|
||||
logger.LogInformation("LocalApplicationData: "+Environment.GetFolderPath(SpecialFolder.LocalApplicationData, SpecialFolderOption.DoNotVerify));
|
||||
|
||||
|
@ -181,8 +181,8 @@
|
||||
var pos = loc.geometry.location;
|
||||
var lat = new Number(pos.lat);
|
||||
var lng = new Number(pos.lng);
|
||||
$('#' + config.latId).val(lat);
|
||||
$('#' + config.longId).val(lng);
|
||||
$('#' + config.latId).val(lat.toLocaleString('en'));
|
||||
$('#' + config.longId).val(lng.toLocaleString('en'));
|
||||
gmap.setCenter(pos);
|
||||
if (marker) {
|
||||
marker.setMap(null);
|
||||
@ -196,8 +196,8 @@
|
||||
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.latId).val(pos.lat.toLocaleString('en'));
|
||||
$('#' + config.longId).val(pos.lng.toLocaleString('en'));
|
||||
});
|
||||
$('#' + config.addrId).valid();
|
||||
$('#' + config.addrValidationId).empty();
|
||||
|
Reference in New Issue
Block a user