diff --git a/Yavsc/ApiControllers/BookQueryApiController.cs b/Yavsc/ApiControllers/BookQueryApiController.cs
index 74d7f54e..96c67b86 100644
--- a/Yavsc/ApiControllers/BookQueryApiController.cs
+++ b/Yavsc/ApiControllers/BookQueryApiController.cs
@@ -34,7 +34,7 @@ namespace Yavsc.Controllers
/// returned Ids must be lower than this value
/// book queries
[HttpGet]
- public IEnumerable GetCommands(long maxId=long.MaxValue)
+ public IEnumerable GetCommands(long maxId=long.MaxValue)
{
var uid = User.GetUserId();
var now = DateTime.Now;
@@ -42,7 +42,7 @@ namespace Yavsc.Controllers
var result = _context.Commands.Include(c => c.Location).
Include(c => c.Client).Where(c => c.PerformerId == uid && c.Id < maxId && c.EventDate > now
&& c.ValidationDate == null).
- Select(c => new BookQueryProviderInfo
+ Select(c => new RdvQueryProviderInfo
{
Client = new ClientProviderInfo {
UserName = c.Client.UserName,
@@ -71,7 +71,7 @@ namespace Yavsc.Controllers
}
var uid = User.GetUserId();
- BookQuery bookQuery = _context.Commands.Where(c => c.ClientId == uid || c.PerformerId == uid).Single(m => m.Id == id);
+ RdvQuery bookQuery = _context.Commands.Where(c => c.ClientId == uid || c.PerformerId == uid).Single(m => m.Id == id);
if (bookQuery == null)
{
@@ -83,7 +83,7 @@ namespace Yavsc.Controllers
// PUT: api/BookQueryApi/5
[HttpPut("{id}")]
- public IActionResult PutBookQuery(long id, [FromBody] BookQuery bookQuery)
+ public IActionResult PutBookQuery(long id, [FromBody] RdvQuery bookQuery)
{
if (!ModelState.IsValid)
{
@@ -121,7 +121,7 @@ namespace Yavsc.Controllers
// POST: api/BookQueryApi
[HttpPost]
- public IActionResult PostBookQuery([FromBody] BookQuery bookQuery)
+ public IActionResult PostBookQuery([FromBody] RdvQuery bookQuery)
{
if (!ModelState.IsValid)
{
@@ -162,7 +162,7 @@ namespace Yavsc.Controllers
return HttpBadRequest(ModelState);
}
var uid = User.GetUserId();
- BookQuery bookQuery = _context.Commands.Single(m => m.Id == id);
+ RdvQuery bookQuery = _context.Commands.Single(m => m.Id == id);
if (bookQuery == null)
{
diff --git a/Yavsc/ApiControllers/EstimateApiController.cs b/Yavsc/ApiControllers/EstimateApiController.cs
index 6ae3ce8c..f2d8b26b 100644
--- a/Yavsc/ApiControllers/EstimateApiController.cs
+++ b/Yavsc/ApiControllers/EstimateApiController.cs
@@ -126,7 +126,7 @@ namespace Yavsc.Controllers
}
}
if (estimate.CommandId!=null) {
- var query = _context.BookQueries.FirstOrDefault(q => q.Id == estimate.CommandId);
+ var query = _context.RdvQueries.FirstOrDefault(q => q.Id == estimate.CommandId);
if (query == null || query.PerformerId!= uid)
throw new InvalidOperationException();
query.ValidationDate = DateTime.Now;
diff --git a/Yavsc/ApiControllers/PerformersApiController.cs b/Yavsc/ApiControllers/PerformersApiController.cs
index 509cf97e..c08e3a50 100644
--- a/Yavsc/ApiControllers/PerformersApiController.cs
+++ b/Yavsc/ApiControllers/PerformersApiController.cs
@@ -51,4 +51,4 @@ namespace Yavsc.Controllers
return new BadRequestObjectResult(ModelState);
}
}
-}
\ No newline at end of file
+}
diff --git a/Yavsc/ApiControllers/ProfileApiController.cs b/Yavsc/ApiControllers/ProfileApiController.cs
index 77426afa..e7d21f9e 100644
--- a/Yavsc/ApiControllers/ProfileApiController.cs
+++ b/Yavsc/ApiControllers/ProfileApiController.cs
@@ -3,6 +3,10 @@ using Microsoft.AspNet.Mvc;
namespace Yavsc.ApiControllers
{
using Models;
+
+ ///
+ /// Base class for managing performers profiles
+ ///
[Produces("application/json"),Route("api/profile")]
public abstract class ProfileApiController : Controller
{
diff --git a/Yavsc/Controllers/CommandController.cs b/Yavsc/Controllers/CommandController.cs
index a1d58653..0f494123 100644
--- a/Yavsc/Controllers/CommandController.cs
+++ b/Yavsc/Controllers/CommandController.cs
@@ -22,16 +22,16 @@ namespace Yavsc.Controllers
[ServiceFilter(typeof(LanguageActionFilter))]
public class CommandController : Controller
{
- private UserManager _userManager;
- private ApplicationDbContext _context;
- private GoogleAuthSettings _googleSettings;
- private IGoogleCloudMessageSender _GCMSender;
- private IEmailSender _emailSender;
- private IStringLocalizer _localizer;
- SiteSettings _siteSettings;
- SmtpSettings _smtpSettings;
+ protected UserManager _userManager;
+ protected ApplicationDbContext _context;
+ protected GoogleAuthSettings _googleSettings;
+ protected IGoogleCloudMessageSender _GCMSender;
+ protected IEmailSender _emailSender;
+ protected IStringLocalizer _localizer;
+ protected SiteSettings _siteSettings;
+ protected SmtpSettings _smtpSettings;
- private readonly ILogger _logger;
+ protected readonly ILogger _logger;
public CommandController(ApplicationDbContext context, IOptions googleSettings,
IGoogleCloudMessageSender GCMSender,
UserManager userManager,
@@ -57,7 +57,7 @@ namespace Yavsc.Controllers
public IActionResult Index()
{
var uid = User.GetUserId();
- return View(_context.BookQueries
+ return View(_context.RdvQueries
.Include(x => x.Client)
.Include(x => x.PerformerProfile)
.Include(x => x.PerformerProfile.Performer)
@@ -74,7 +74,7 @@ namespace Yavsc.Controllers
return HttpNotFound();
}
- BookQuery command = _context.BookQueries
+ RdvQuery command = _context.RdvQueries
.Include(x => x.Location)
.Include(x => x.PerformerProfile)
.Single(m => m.Id == id);
@@ -113,7 +113,7 @@ namespace Yavsc.Controllers
ViewBag.GoogleSettings = _googleSettings;
var userid = User.GetUserId();
var user = _userManager.FindByIdAsync(userid).Result;
- return View(new BookQuery(activityCode,new Location(),DateTime.Now.AddHours(4))
+ return View(new RdvQuery(activityCode,new Location(),DateTime.Now.AddHours(4))
{
PerformerProfile = pro,
PerformerId = pro.PerformerId,
@@ -126,7 +126,7 @@ namespace Yavsc.Controllers
// POST: Command/Create
[HttpPost, Authorize]
[ValidateAntiForgeryToken]
- public async Task Create(BookQuery command)
+ public async Task Create(RdvQuery command)
{
var uid = User.GetUserId();
@@ -161,7 +161,7 @@ namespace Yavsc.Controllers
command.Location=existingLocation;
}
else _context.Attach(command.Location);
- _context.BookQueries.Add(command, GraphBehavior.IncludeDependents);
+ _context.RdvQueries.Add(command, GraphBehavior.IncludeDependents);
_context.SaveChanges(User.GetUserId());
var yaev = command.CreateEvent(_localizer);
@@ -206,7 +206,7 @@ namespace Yavsc.Controllers
return HttpNotFound();
}
- BookQuery command = _context.BookQueries.Single(m => m.Id == id);
+ RdvQuery command = _context.RdvQueries.Single(m => m.Id == id);
if (command == null)
{
return HttpNotFound();
@@ -217,7 +217,7 @@ namespace Yavsc.Controllers
// POST: Command/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
- public IActionResult Edit(BookQuery command)
+ public IActionResult Edit(RdvQuery command)
{
if (ModelState.IsValid)
{
@@ -237,7 +237,7 @@ namespace Yavsc.Controllers
return HttpNotFound();
}
- BookQuery command = _context.BookQueries.Single(m => m.Id == id);
+ RdvQuery command = _context.RdvQueries.Single(m => m.Id == id);
if (command == null)
{
return HttpNotFound();
@@ -251,8 +251,8 @@ namespace Yavsc.Controllers
[ValidateAntiForgeryToken]
public IActionResult DeleteConfirmed(long id)
{
- BookQuery command = _context.BookQueries.Single(m => m.Id == id);
- _context.BookQueries.Remove(command);
+ RdvQuery command = _context.RdvQueries.Single(m => m.Id == id);
+ _context.RdvQueries.Remove(command);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
diff --git a/Yavsc/Controllers/EstimateController.cs b/Yavsc/Controllers/EstimateController.cs
index 288d914c..01184d20 100644
--- a/Yavsc/Controllers/EstimateController.cs
+++ b/Yavsc/Controllers/EstimateController.cs
@@ -81,7 +81,7 @@ namespace Yavsc.Controllers
public IActionResult Create()
{
var uid = User.GetUserId();
- IQueryable queries = _context.BookQueries.Include(q=>q.Location).Where(bq=>bq.PerformerId == uid);
+ IQueryable queries = _context.RdvQueries.Include(q=>q.Location).Where(bq=>bq.PerformerId == uid);
//.Select(bq=>new SelectListItem{ Text = bq.Client.UserName, Value = bq.Client.Id });
ViewBag.Clients = queries.Select(q=>q.Client).Distinct();
ViewBag.Queries = queries;
@@ -103,7 +103,7 @@ namespace Yavsc.Controllers
_context.Estimates
.Add(estimate);
_context.SaveChanges(User.GetUserId());
- var query = _context.BookQueries.FirstOrDefault(
+ var query = _context.RdvQueries.FirstOrDefault(
q=>q.Id == estimate.CommandId
);
var perfomerProfile = _context.Performers
@@ -111,7 +111,7 @@ namespace Yavsc.Controllers
perpr => perpr.Performer).FirstOrDefault(
x=>x.PerformerId == query.PerformerId
);
- var command = _context.BookQueries.FirstOrDefault(
+ var command = _context.RdvQueries.FirstOrDefault(
cmd => cmd.Id == estimate.CommandId
);
diff --git a/Yavsc/Controllers/FrontOfficeController.cs b/Yavsc/Controllers/FrontOfficeController.cs
index 31635d73..c5cee49b 100644
--- a/Yavsc/Controllers/FrontOfficeController.cs
+++ b/Yavsc/Controllers/FrontOfficeController.cs
@@ -10,9 +10,13 @@ using System.Security.Claims;
namespace Yavsc.Controllers
{
using Helpers;
+ using Microsoft.AspNet.Http;
using Models;
- using Models.Workflow;
+ using Newtonsoft.Json;
using ViewModels.FrontOffice;
+ using Yavsc.Models.Haircut;
+ using Yavsc.ViewModels.Haircut;
+
public class FrontOfficeController : Controller
{
ApplicationDbContext _context;
@@ -46,7 +50,7 @@ namespace Yavsc.Controllers
return View(model);
}
- [Route("Profiles/{id?}"), HttpGet, AllowAnonymous]
+ [AllowAnonymous]
public ActionResult Profiles(string id)
{
if (id == null)
@@ -57,40 +61,28 @@ namespace Yavsc.Controllers
var result = _context.ListPerformers(id);
return View(result);
}
-
- [Route("Profiles/{id}"), HttpPost, AllowAnonymous]
- public ActionResult Profiles(BookQuery bookQuery)
+
+ [AllowAnonymous]
+ public ActionResult HairCut(string id)
{
- if (ModelState.IsValid)
- {
- var pro = _context.Performers.Include(
- pr => pr.Performer
- ).FirstOrDefault(
- x => x.PerformerId == bookQuery.PerformerId
- );
- if (pro == null)
- return HttpNotFound();
- // Let's create a command
- if (bookQuery.Id == 0)
- {
- _context.BookQueries.Add(bookQuery);
- }
- else
- {
- _context.BookQueries.Update(bookQuery);
- }
- _context.SaveChanges(User.GetUserId());
- // TODO Send sys notifications &
- // notify the user (make him a basket badge)
- return View("Index");
+ HairPrestation pPrestation=null;
+ var prestaJson = HttpContext.Session.GetString("HairCutPresta") ;
+ if (prestaJson!=null) {
+ pPrestation = JsonConvert.DeserializeObject(prestaJson);
}
- ViewBag.Activities = _context.ActivityItems(null);
- return View("Profiles", _context.Performers.Include(p => p.Performer).Where
- (p => p.Active).OrderBy(
- x => x.MinDailyCost
- ));
+ else pPrestation = new HairPrestation {
+
+ };
+
+ ViewBag.Activity = _context.Activities.First(a => a.Code == id);
+ var result = new HairCutView {
+ HairBrushers = _context.ListPerformers(id),
+ Topic = pPrestation
+ } ;
+ return View(result);
}
+
[Produces("text/x-tex"), Authorize, Route("estimate-{id}.tex")]
public ViewResult EstimateTex(long id)
{
diff --git a/Yavsc/Controllers/HairCutCommandController.cs b/Yavsc/Controllers/HairCutCommandController.cs
new file mode 100644
index 00000000..0de5571d
--- /dev/null
+++ b/Yavsc/Controllers/HairCutCommandController.cs
@@ -0,0 +1,189 @@
+using System;
+using System.Linq;
+using System.Security.Claims;
+using System.Threading.Tasks;
+using Microsoft.AspNet.Authorization;
+using Microsoft.AspNet.Identity;
+using Microsoft.AspNet.Mvc;
+using Microsoft.Data.Entity;
+using Microsoft.Extensions.Localization;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.OptionsModel;
+using Yavsc.Helpers;
+using Yavsc.Models;
+using Yavsc.Models.Google.Messaging;
+using Yavsc.Models.Haircut;
+using Yavsc.Models.Relationship;
+using Yavsc.Services;
+
+namespace Yavsc.Controllers
+{
+ public class HairCutCommandController : CommandController
+ {
+ public HairCutCommandController(ApplicationDbContext context,
+ IOptions googleSettings,
+ IGoogleCloudMessageSender GCMSender,
+ UserManager userManager,
+ IStringLocalizer localizer,
+ IEmailSender emailSender,
+ IOptions smtpSettings,
+ IOptions siteSettings,
+ ILoggerFactory loggerFactory) : base(context,googleSettings,GCMSender,userManager,
+ localizer,emailSender,smtpSettings,siteSettings,loggerFactory)
+ {
+
+ }
+
+ [HttpPost, Authorize]
+ [ValidateAntiForgeryToken]
+ public async Task CreateHairCutQuery(HairCutQuery command)
+ {
+
+
+ var uid = User.GetUserId();
+ var prid = command.PerformerId;
+ 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 == command.PerformerId
+ );
+ var user = await _userManager.FindByIdAsync(uid);
+ command.Client = user;
+ command.ClientId = uid;
+ command.PerformerProfile = pro;
+ // FIXME Why!!
+ // ModelState.ClearValidationState("PerformerProfile.Avatar");
+ // ModelState.ClearValidationState("Client.Avatar");
+ // ModelState.ClearValidationState("ClientId");
+ ModelState.MarkFieldSkipped("ClientId");
+
+ if (ModelState.IsValid)
+ {
+ var existingLocation = _context.Locations.FirstOrDefault( x=>x.Address == command.Location.Address
+ && x.Longitude == command.Location.Longitude && x.Latitude == command.Location.Latitude );
+
+ if (existingLocation!=null) {
+ command.Location=existingLocation;
+ }
+ else _context.Attach(command.Location);
+
+ _context.HairCutQueries.Add(command, GraphBehavior.IncludeDependents);
+ _context.SaveChanges(User.GetUserId());
+
+ var yaev = command.CreateEvent(_localizer);
+ MessageWithPayloadResponse grep = null;
+
+ if (pro.AcceptNotifications
+ && pro.AcceptPublicContact)
+ {
+ if (pro.Performer.Devices.Count > 0) {
+ var regids = command.PerformerProfile.Performer
+ .Devices.Select(d => d.GCMRegistrationId);
+ grep = await _GCMSender.NotifyHairCutQueryAsync(_googleSettings,regids,yaev);
+ }
+ // TODO setup a profile choice to allow notifications
+ // both on mailbox and mobile
+ // if (grep==null || grep.success<=0 || grep.failure>0)
+ ViewBag.GooglePayload=grep;
+ if (grep!=null)
+ _logger.LogWarning($"Performer: {command.PerformerProfile.Performer.UserName} success: {grep.success} failure: {grep.failure}");
+
+ await _emailSender.SendEmailAsync(
+ _siteSettings, _smtpSettings,
+ command.PerformerProfile.Performer.Email,
+ yaev.Topic+" "+yaev.Sender,
+ $"{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.GoogleSettings = _googleSettings;
+ return View("CommandConfirmation",command);
+ }
+ ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == command.ActivityCode);
+ ViewBag.GoogleSettings = _googleSettings;
+ return View(command);
+
+ }
+
+ [HttpPost, Authorize]
+ [ValidateAntiForgeryToken]
+ public async Task CreateHairMultiCutQuery(HairMultiCutQuery command)
+ {
+
+ var uid = User.GetUserId();
+ var prid = command.PerformerId;
+ 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 == command.PerformerId
+ );
+ var user = await _userManager.FindByIdAsync(uid);
+ command.Client = user;
+ command.ClientId = uid;
+ command.PerformerProfile = pro;
+ // FIXME Why!!
+ // ModelState.ClearValidationState("PerformerProfile.Avatar");
+ // ModelState.ClearValidationState("Client.Avatar");
+ // ModelState.ClearValidationState("ClientId");
+ ModelState.MarkFieldSkipped("ClientId");
+
+ if (ModelState.IsValid)
+ {
+ var existingLocation = _context.Locations.FirstOrDefault( x=>x.Address == command.Location.Address
+ && x.Longitude == command.Location.Longitude && x.Latitude == command.Location.Latitude );
+
+ if (existingLocation!=null) {
+ command.Location=existingLocation;
+ }
+ else _context.Attach(command.Location);
+
+ _context.HairMultiCutQueries.Add(command, GraphBehavior.IncludeDependents);
+ _context.SaveChanges(User.GetUserId());
+
+ var yaev = command.CreateEvent(_localizer);
+ MessageWithPayloadResponse grep = null;
+
+ if (pro.AcceptNotifications
+ && pro.AcceptPublicContact)
+ {
+ if (pro.Performer.Devices.Count > 0) {
+ var regids = command.PerformerProfile.Performer
+ .Devices.Select(d => d.GCMRegistrationId);
+ grep = await _GCMSender.NotifyHairCutQueryAsync(_googleSettings,regids,yaev);
+ }
+ // TODO setup a profile choice to allow notifications
+ // both on mailbox and mobile
+ // if (grep==null || grep.success<=0 || grep.failure>0)
+ ViewBag.GooglePayload=grep;
+ if (grep!=null)
+ _logger.LogWarning($"Performer: {command.PerformerProfile.Performer.UserName} success: {grep.success} failure: {grep.failure}");
+
+ await _emailSender.SendEmailAsync(
+ _siteSettings, _smtpSettings,
+ command.PerformerProfile.Performer.Email,
+ yaev.Topic+" "+yaev.Sender,
+ $"{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.GoogleSettings = _googleSettings;
+ return View("CommandConfirmation",command);
+ }
+ ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == command.ActivityCode);
+ ViewBag.GoogleSettings = _googleSettings;
+ return View(command);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Yavsc/Controllers/HairPrestationsController.cs b/Yavsc/Controllers/HairPrestationsController.cs
new file mode 100644
index 00000000..93e081bc
--- /dev/null
+++ b/Yavsc/Controllers/HairPrestationsController.cs
@@ -0,0 +1,122 @@
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNet.Mvc;
+using Microsoft.AspNet.Mvc.Rendering;
+using Microsoft.Data.Entity;
+using Yavsc.Models;
+using Yavsc.Models.Haircut;
+
+namespace Yavsc.Controllers
+{
+ public class HairPrestationsController : Controller
+ {
+ private ApplicationDbContext _context;
+
+ public HairPrestationsController(ApplicationDbContext context)
+ {
+ _context = context;
+ }
+
+ // GET: HairPrestations
+ public async Task Index()
+ {
+ return View(await _context.HairPrestation.ToListAsync());
+ }
+
+ // GET: HairPrestations/Details/5
+ public async Task Details(long? id)
+ {
+ if (id == null)
+ {
+ return HttpNotFound();
+ }
+
+ HairPrestation hairPrestation = await _context.HairPrestation.SingleAsync(m => m.Id == id);
+ if (hairPrestation == null)
+ {
+ return HttpNotFound();
+ }
+
+ return View(hairPrestation);
+ }
+
+ // GET: HairPrestations/Create
+ public IActionResult Create()
+ {
+ return View();
+ }
+
+ // POST: HairPrestations/Create
+ [HttpPost]
+ [ValidateAntiForgeryToken]
+ public async Task Create(HairPrestation hairPrestation)
+ {
+ if (ModelState.IsValid)
+ {
+ _context.HairPrestation.Add(hairPrestation);
+ await _context.SaveChangesAsync();
+ return RedirectToAction("Index");
+ }
+ return View(hairPrestation);
+ }
+
+ // GET: HairPrestations/Edit/5
+ public async Task Edit(long? id)
+ {
+ if (id == null)
+ {
+ return HttpNotFound();
+ }
+
+ HairPrestation hairPrestation = await _context.HairPrestation.SingleAsync(m => m.Id == id);
+ if (hairPrestation == null)
+ {
+ return HttpNotFound();
+ }
+ return View(hairPrestation);
+ }
+
+ // POST: HairPrestations/Edit/5
+ [HttpPost]
+ [ValidateAntiForgeryToken]
+ public async Task Edit(HairPrestation hairPrestation)
+ {
+ if (ModelState.IsValid)
+ {
+ _context.Update(hairPrestation);
+ await _context.SaveChangesAsync();
+ return RedirectToAction("Index");
+ }
+ return View(hairPrestation);
+ }
+
+ // GET: HairPrestations/Delete/5
+ [ActionName("Delete")]
+ public async Task Delete(long? id)
+ {
+ if (id == null)
+ {
+ return HttpNotFound();
+ }
+
+ HairPrestation hairPrestation = await _context.HairPrestation.SingleAsync(m => m.Id == id);
+ if (hairPrestation == null)
+ {
+ return HttpNotFound();
+ }
+
+ return View(hairPrestation);
+ }
+
+ // POST: HairPrestations/Delete/5
+ [HttpPost, ActionName("Delete")]
+ [ValidateAntiForgeryToken]
+ public async Task DeleteConfirmed(long id)
+ {
+ HairPrestation hairPrestation = await _context.HairPrestation.SingleAsync(m => m.Id == id);
+ _context.HairPrestation.Remove(hairPrestation);
+ await _context.SaveChangesAsync();
+ return RedirectToAction("Index");
+ }
+ }
+}
diff --git a/Yavsc/Controllers/ManageController.cs b/Yavsc/Controllers/ManageController.cs
index 34649b19..dd472b08 100644
--- a/Yavsc/Controllers/ManageController.cs
+++ b/Yavsc/Controllers/ManageController.cs
@@ -103,7 +103,7 @@ namespace Yavsc.Controllers
UserName = user.UserName,
PostsCounter = pc,
Balance = user.AccountBalance,
- ActiveCommandCount = _dbContext.BookQueries.Count(x => (x.ClientId == user.Id) && (x.EventDate > DateTime.Now)),
+ ActiveCommandCount = _dbContext.RdvQueries.Count(x => (x.ClientId == user.Id) && (x.EventDate > DateTime.Now)),
HasDedicatedCalendar = !string.IsNullOrEmpty(user.DedicatedGoogleCalendar),
Roles = await _userManager.GetRolesAsync(user),
PostalAddress = user.PostalAddress?.Address,
diff --git a/Yavsc/Helpers/EventHelpers.cs b/Yavsc/Helpers/EventHelpers.cs
index 67c180e7..943c238c 100644
--- a/Yavsc/Helpers/EventHelpers.cs
+++ b/Yavsc/Helpers/EventHelpers.cs
@@ -4,13 +4,22 @@ namespace Yavsc.Helpers
{
using Models.Workflow;
using Models.Messaging;
+ using Yavsc.Models.Haircut;
+
public static class EventHelpers
{
- public static BookQueryEvent CreateEvent(this BookQuery query,
+ public static RdvQueryEvent CreateEvent(this RdvQuery query,
IStringLocalizer SR)
{
- var yaev = new BookQueryEvent
- {
+ var yaev = new RdvQueryEvent
+ {
+ Sender = query.ClientId,
+ Message = string.Format(SR["RdvToPerf"],
+ query.Client.UserName,
+ query.EventDate.ToString("dddd dd/MM/yyyy à HH:mm"),
+ query.Location.Address,
+ query.ActivityCode)+
+ "\n"+query.Reason,
Client = new ClientProviderInfo {
UserName = query.Client.UserName ,
UserId = query.ClientId,
@@ -24,6 +33,54 @@ namespace Yavsc.Helpers
};
return yaev;
}
-
+ public static HairCutQueryEvent CreateEvent(this HairCutQuery query,
+ IStringLocalizer SR)
+ {
+ var yaev = new HairCutQueryEvent
+ {
+ Sender = query.ClientId,
+ Message = string.Format(SR["RdvToPerf"],
+ query.Client.UserName,
+ query.EventDate.ToString("dddd dd/MM/yyyy à HH:mm"),
+ query.Location.Address,
+ query.ActivityCode),
+ Client = new ClientProviderInfo {
+ UserName = query.Client.UserName ,
+ UserId = query.ClientId,
+ Avatar = query.Client.Avatar } ,
+ Previsional = query.Previsional,
+ EventDate = query.EventDate,
+ Location = query.Location,
+ Id = query.Id,
+ Reason = "Coupe particulier",
+ ActivityCode = query.ActivityCode
+ };
+ return yaev;
+ }
+
+ public static HairCutQueryEvent CreateEvent(this HairMultiCutQuery query,
+ IStringLocalizer SR)
+ {
+ var yaev = new HairCutQueryEvent
+ {
+ Sender = query.ClientId,
+ Message = string.Format(SR["RdvToPerf"],
+ query.Client.UserName,
+ query.EventDate.ToString("dddd dd/MM/yyyy à HH:mm"),
+ query.Location.Address,
+ query.ActivityCode),
+ Client = new ClientProviderInfo {
+ UserName = query.Client.UserName ,
+ UserId = query.ClientId,
+ Avatar = query.Client.Avatar } ,
+ Previsional = query.Previsional,
+ EventDate = query.EventDate,
+ Location = query.Location,
+ Id = query.Id,
+ Reason = "Commande groupée!",
+ ActivityCode = query.ActivityCode
+ };
+ return yaev;
+ }
}
}
diff --git a/Yavsc/Migrations/20170227151759_hairPrestations.Designer.cs b/Yavsc/Migrations/20170227151759_hairPrestations.Designer.cs
new file mode 100644
index 00000000..b0287338
--- /dev/null
+++ b/Yavsc/Migrations/20170227151759_hairPrestations.Designer.cs
@@ -0,0 +1,1329 @@
+using System;
+using Microsoft.Data.Entity;
+using Microsoft.Data.Entity.Infrastructure;
+using Microsoft.Data.Entity.Metadata;
+using Microsoft.Data.Entity.Migrations;
+using Yavsc.Models;
+
+namespace Yavsc.Migrations
+{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20170227151759_hairPrestations")]
+ partial class hairPrestations
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.0-rc1-16348");
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRole", b =>
+ {
+ b.Property("Id");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken();
+
+ b.Property("Name")
+ .HasAnnotation("MaxLength", 256);
+
+ b.Property("NormalizedName")
+ .HasAnnotation("MaxLength", 256);
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedName")
+ .HasAnnotation("Relational:Name", "RoleNameIndex");
+
+ b.HasAnnotation("Relational:TableName", "AspNetRoles");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRoleClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ClaimType");
+
+ b.Property("ClaimValue");
+
+ b.Property("RoleId")
+ .IsRequired();
+
+ b.HasKey("Id");
+
+ b.HasAnnotation("Relational:TableName", "AspNetRoleClaims");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ClaimType");
+
+ b.Property("ClaimValue");
+
+ b.Property("UserId")
+ .IsRequired();
+
+ b.HasKey("Id");
+
+ b.HasAnnotation("Relational:TableName", "AspNetUserClaims");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin", b =>
+ {
+ b.Property("LoginProvider");
+
+ b.Property("ProviderKey");
+
+ b.Property("ProviderDisplayName");
+
+ b.Property("UserId")
+ .IsRequired();
+
+ b.HasKey("LoginProvider", "ProviderKey");
+
+ b.HasAnnotation("Relational:TableName", "AspNetUserLogins");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole", b =>
+ {
+ b.Property("UserId");
+
+ b.Property("RoleId");
+
+ b.HasKey("UserId", "RoleId");
+
+ b.HasAnnotation("Relational:TableName", "AspNetUserRoles");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Access.Ban", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("DateCreated");
+
+ b.Property("DateModified");
+
+ b.Property("UserCreated");
+
+ b.Property("UserModified");
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Access.BlackListed", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("OwnerId")
+ .IsRequired();
+
+ b.Property("UserId")
+ .IsRequired();
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Access.CircleAuthorizationToBlogPost", b =>
+ {
+ b.Property("CircleId");
+
+ b.Property("BlogPostId");
+
+ b.HasKey("CircleId", "BlogPostId");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.AccountBalance", b =>
+ {
+ b.Property("UserId");
+
+ b.Property("ContactCredits");
+
+ b.Property("Credits");
+
+ b.HasKey("UserId");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.ApplicationUser", b =>
+ {
+ b.Property("Id");
+
+ b.Property("AccessFailedCount");
+
+ b.Property("Avatar")
+ .IsRequired()
+ .HasAnnotation("MaxLength", 512)
+ .HasAnnotation("Relational:DefaultValue", "/images/Users/icon_user.png")
+ .HasAnnotation("Relational:DefaultValueType", "System.String");
+
+ b.Property("BankInfoId");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken();
+
+ b.Property("DedicatedGoogleCalendar");
+
+ b.Property("DiskQuota")
+ .HasAnnotation("Relational:DefaultValue", "524288000")
+ .HasAnnotation("Relational:DefaultValueType", "System.Int64");
+
+ b.Property("DiskUsage");
+
+ b.Property("Email")
+ .HasAnnotation("MaxLength", 256);
+
+ b.Property("EmailConfirmed");
+
+ b.Property("FullName")
+ .HasAnnotation("MaxLength", 512);
+
+ b.Property("LockoutEnabled");
+
+ b.Property("LockoutEnd");
+
+ b.Property("NormalizedEmail")
+ .HasAnnotation("MaxLength", 256);
+
+ b.Property("NormalizedUserName")
+ .HasAnnotation("MaxLength", 256);
+
+ b.Property("PasswordHash");
+
+ b.Property("PhoneNumber");
+
+ b.Property("PhoneNumberConfirmed");
+
+ b.Property("PostalAddressId");
+
+ b.Property("SecurityStamp");
+
+ b.Property("TwoFactorEnabled");
+
+ b.Property("UserName")
+ .HasAnnotation("MaxLength", 256);
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedEmail")
+ .HasAnnotation("Relational:Name", "EmailIndex");
+
+ b.HasIndex("NormalizedUserName")
+ .HasAnnotation("Relational:Name", "UserNameIndex");
+
+ b.HasAnnotation("Relational:TableName", "AspNetUsers");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Auth.Client", b =>
+ {
+ b.Property("Id");
+
+ b.Property("Active");
+
+ b.Property("DisplayName");
+
+ b.Property("LogoutRedirectUri")
+ .HasAnnotation("MaxLength", 100);
+
+ b.Property("RedirectUri");
+
+ b.Property("RefreshTokenLifeTime");
+
+ b.Property("Secret");
+
+ b.Property("Type");
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Auth.RefreshToken", b =>
+ {
+ b.Property("Id");
+
+ b.Property("ClientId")
+ .IsRequired()
+ .HasAnnotation("MaxLength", 50);
+
+ b.Property("ExpiresUtc");
+
+ b.Property("IssuedUtc");
+
+ b.Property("ProtectedTicket")
+ .IsRequired();
+
+ b.Property("Subject")
+ .IsRequired()
+ .HasAnnotation("MaxLength", 50);
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.BalanceImpact", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("BalanceId")
+ .IsRequired();
+
+ b.Property("ExecDate");
+
+ b.Property("Impact");
+
+ b.Property("Reason")
+ .IsRequired();
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Bank.BankIdentity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("AccountNumber")
+ .HasAnnotation("MaxLength", 15);
+
+ b.Property("BIC")
+ .HasAnnotation("MaxLength", 15);
+
+ b.Property("BankCode")
+ .HasAnnotation("MaxLength", 5);
+
+ b.Property("BankedKey");
+
+ b.Property("IBAN")
+ .HasAnnotation("MaxLength", 33);
+
+ b.Property("WicketCode")
+ .HasAnnotation("MaxLength", 5);
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Billing.CommandLine", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Count");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasAnnotation("MaxLength", 512);
+
+ b.Property("EstimateId");
+
+ b.Property("EstimateTemplateId");
+
+ b.Property("UnitaryCost");
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Billing.Estimate", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("AttachedFilesString");
+
+ b.Property("AttachedGraphicsString");
+
+ b.Property("ClientId")
+ .IsRequired();
+
+ b.Property("ClientValidationDate");
+
+ b.Property("CommandId");
+
+ b.Property("CommandType");
+
+ b.Property("Description");
+
+ b.Property("OwnerId")
+ .IsRequired();
+
+ b.Property("ProviderValidationDate");
+
+ b.Property("Title");
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Billing.EstimateTemplate", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Description");
+
+ b.Property("OwnerId")
+ .IsRequired();
+
+ b.Property("Title");
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Billing.ExceptionSIREN", b =>
+ {
+ b.Property("SIREN");
+
+ b.HasKey("SIREN");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Blog", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("AuthorId");
+
+ b.Property("Content");
+
+ b.Property("DateCreated");
+
+ b.Property("DateModified");
+
+ b.Property("Photo");
+
+ b.Property("Rate");
+
+ b.Property("Title");
+
+ b.Property("UserCreated");
+
+ b.Property("UserModified");
+
+ b.Property("Visible");
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Chat.Connection", b =>
+ {
+ b.Property("ConnectionId");
+
+ b.Property("ApplicationUserId");
+
+ b.Property("Connected");
+
+ b.Property("UserAgent");
+
+ b.HasKey("ConnectionId");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Drawing.Color", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Blue");
+
+ b.Property("Green");
+
+ b.Property("Name");
+
+ b.Property("Red");
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Forms.Form", b =>
+ {
+ b.Property("Id");
+
+ b.Property("Summary");
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Haircut.HairCutQuery", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ActivityCode")
+ .IsRequired();
+
+ b.Property("ClientId")
+ .IsRequired();
+
+ b.Property("DateCreated");
+
+ b.Property("DateModified");
+
+ b.Property("EventDate");
+
+ b.Property("LocationId");
+
+ b.Property("PerformerId")
+ .IsRequired();
+
+ b.Property("PrestationId");
+
+ b.Property("Previsional");
+
+ b.Property("Status");
+
+ b.Property("UserCreated");
+
+ b.Property("UserModified");
+
+ b.Property("ValidationDate");
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Haircut.HairMultiCutQuery", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ActivityCode")
+ .IsRequired();
+
+ b.Property("ClientId")
+ .IsRequired();
+
+ b.Property("DateCreated");
+
+ b.Property("DateModified");
+
+ b.Property("EventDate");
+
+ b.Property("LocationId");
+
+ b.Property("PerformerId")
+ .IsRequired();
+
+ b.Property("Previsional");
+
+ b.Property("Status");
+
+ b.Property("UserCreated");
+
+ b.Property("UserModified");
+
+ b.Property("ValidationDate");
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Haircut.HairPrestation", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Cares");
+
+ b.Property("Cut");
+
+ b.Property("Dressing");
+
+ b.Property("Gender");
+
+ b.Property("HairMultiCutQueryId");
+
+ b.Property("Length");
+
+ b.Property("Shampoo");
+
+ b.Property("Tech");
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Haircut.HairTaint", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Brand");
+
+ b.Property("ColorId");
+
+ b.Property("HairPrestationId");
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Identity.GoogleCloudMobileDeclaration", b =>
+ {
+ b.Property("DeviceId");
+
+ b.Property("DeclarationDate")
+ .ValueGeneratedOnAdd()
+ .HasAnnotation("Relational:GeneratedValueSql", "LOCALTIMESTAMP");
+
+ b.Property("DeviceOwnerId");
+
+ b.Property("GCMRegistrationId")
+ .IsRequired();
+
+ b.Property("Model");
+
+ b.Property("Platform");
+
+ b.Property("Version");
+
+ b.HasKey("DeviceId");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Market.Product", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Depth");
+
+ b.Property("Description");
+
+ b.Property("Height");
+
+ b.Property("Name");
+
+ b.Property("Price");
+
+ b.Property("Public");
+
+ b.Property("Weight");
+
+ b.Property("Width");
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Market.Service", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ContextId");
+
+ b.Property("Description");
+
+ b.Property("Name");
+
+ b.Property("Public");
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Messaging.ClientProviderInfo", b =>
+ {
+ b.Property("UserId");
+
+ b.Property("Avatar");
+
+ b.Property("BillingAddressId");
+
+ b.Property("EMail");
+
+ b.Property("Phone");
+
+ b.Property("UserName");
+
+ b.HasKey("UserId");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Messaging.DimissClicked", b =>
+ {
+ b.Property("UserId");
+
+ b.Property("NotificationId");
+
+ b.HasKey("UserId", "NotificationId");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Messaging.Notification", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("body")
+ .IsRequired();
+
+ b.Property("click_action")
+ .IsRequired();
+
+ b.Property("color");
+
+ b.Property("icon");
+
+ b.Property("sound");
+
+ b.Property("tag");
+
+ b.Property("title")
+ .IsRequired();
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Musical.Instrument", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Name")
+ .IsRequired()
+ .HasAnnotation("MaxLength", 255);
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Musical.MusicalPreference", b =>
+ {
+ b.Property("OwnerProfileId");
+
+ b.Property("DjSettingsUserId");
+
+ b.Property("GeneralSettingsUserId");
+
+ b.Property("Rate");
+
+ b.Property("TendencyId");
+
+ b.HasKey("OwnerProfileId");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Musical.MusicalTendency", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Name")
+ .IsRequired()
+ .HasAnnotation("MaxLength", 255);
+
+ b.HasKey("Id");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Musical.Profiles.DjSettings", b =>
+ {
+ b.Property("UserId");
+
+ b.Property("SoundCloudId");
+
+ b.HasKey("UserId");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Musical.Profiles.GeneralSettings", b =>
+ {
+ b.Property("UserId");
+
+ b.HasKey("UserId");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Musical.Profiles.Instrumentation", b =>
+ {
+ b.Property("InstrumentId");
+
+ b.Property("UserId");
+
+ b.HasKey("InstrumentId", "UserId");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.OAuth.OAuth2Tokens", b =>
+ {
+ b.Property("UserId");
+
+ b.Property("AccessToken");
+
+ b.Property("Expiration");
+
+ b.Property("ExpiresIn");
+
+ b.Property("RefreshToken");
+
+ b.Property("TokenType");
+
+ b.HasKey("UserId");
+ });
+
+ modelBuilder.Entity("Yavsc.Models.Relationship.Circle", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property