|
|
|
@ -126,8 +126,10 @@ Le client final: {clientFinal}
|
|
|
|
|
|
|
|
|
|
|
|
");
|
|
|
|
");
|
|
|
|
|
|
|
|
|
|
|
|
if (command.PerformerProfile.AcceptNotifications) {
|
|
|
|
if (command.PerformerProfile.AcceptNotifications)
|
|
|
|
if (command.PerformerProfile.Performer.Devices.Count > 0) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (command.PerformerProfile.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);
|
|
|
|
@ -145,7 +147,8 @@ Le client final: {clientFinal}
|
|
|
|
$"{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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -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,48 +232,56 @@ 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"
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(
|
|
|
|
var pro = _context.Performers.Include(
|
|
|
|
u => u.Performer
|
|
|
|
u => u.Performer
|
|
|
|
).Include(u => u.Performer.Devices)
|
|
|
|
).Include(u => u.Performer.Devices)
|
|
|
|
.FirstOrDefault(
|
|
|
|
.FirstOrDefault(
|
|
|
|
x => x.PerformerId == model.PerformerId
|
|
|
|
x => x.PerformerId == model.PerformerId
|
|
|
|
);
|
|
|
|
);
|
|
|
|
model.PerformerProfile = pro;
|
|
|
|
using (var trans = _context.Database.BeginTransaction())
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!model.Consent)
|
|
|
|
|
|
|
|
ModelState.AddModelError("Consent", "Vous devez accepter les conditions générales de vente de ce service");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
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();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (var trans = _context.Database.BeginTransaction()) {
|
|
|
|
|
|
|
|
// Une prestation pour enfant ou homme inclut toujours la coupe.
|
|
|
|
// 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
|
|
|
|
var existingLocation = await _context.Locations.FirstOrDefaultAsync(x => x.Address == model.Location.Address
|
|
|
|
&& x.Longitude == model.Location.Longitude && x.Latitude == model.Location.Latitude);
|
|
|
|
&& x.Longitude == model.Location.Longitude && x.Latitude == model.Location.Latitude);
|
|
|
|
|
|
|
|
|
|
|
|
if (existingLocation!=null) {
|
|
|
|
if (existingLocation != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
model.Location = existingLocation;
|
|
|
|
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);
|
|
|
|
@ -290,10 +301,11 @@ 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);
|
|
|
|
{
|
|
|
|
|
|
|
|
var regids = pro.Performer.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
|
|
|
|
@ -301,10 +313,11 @@ Le client final: {clientFinal}
|
|
|
|
// 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,
|
|
|
|
@ -319,12 +332,13 @@ 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);
|
|
|
|
@ -345,10 +359,12 @@ Le client final: {clientFinal}
|
|
|
|
{
|
|
|
|
{
|
|
|
|
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 { };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -360,7 +376,8 @@ Le client final: {clientFinal}
|
|
|
|
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,
|
|
|
|
@ -376,7 +393,8 @@ Le client final: {clientFinal}
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -424,7 +442,8 @@ Le client final: {clientFinal}
|
|
|
|
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);
|
|
|
|
@ -440,7 +459,8 @@ Le client final: {clientFinal}
|
|
|
|
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);
|
|
|
|
@ -453,7 +473,8 @@ Le client final: {clientFinal}
|
|
|
|
_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,
|
|
|
|
|