refact
This commit is contained in:
@ -58,8 +58,8 @@ namespace Yavsc.Controllers
|
||||
return View(result);
|
||||
}
|
||||
|
||||
[Route("Book/{id}"), HttpPost, AllowAnonymous]
|
||||
public ActionResult Book(BookQuery bookQuery)
|
||||
[Route("Profiles/{id}"), HttpPost, AllowAnonymous]
|
||||
public ActionResult Profiles(BookQuery bookQuery)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
@ -85,7 +85,7 @@ namespace Yavsc.Controllers
|
||||
return View("Index");
|
||||
}
|
||||
ViewBag.Activities = _context.ActivityItems(null);
|
||||
return View("Book", _context.Performers.Include(p => p.Performer).Where
|
||||
return View("Profiles", _context.Performers.Include(p => p.Performer).Where
|
||||
(p => p.Active).OrderBy(
|
||||
x => x.MinDailyCost
|
||||
));
|
||||
|
@ -1,12 +1,13 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Haircut;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Models;
|
||||
using Models.Haircut;
|
||||
[Authorize("AdministratorOnly")]
|
||||
public class HairTaintsController : Controller
|
||||
{
|
||||
@ -20,7 +21,8 @@ namespace Yavsc.Controllers
|
||||
// GET: HairTaints
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.HairTaint.ToListAsync());
|
||||
var applicationDbContext = _context.HairTaint.Include(h => h.Color);
|
||||
return View(await applicationDbContext.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: HairTaints/Details/5
|
||||
@ -43,6 +45,7 @@ namespace Yavsc.Controllers
|
||||
// GET: HairTaints/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name");
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -57,6 +60,7 @@ namespace Yavsc.Controllers
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name", hairTaint.ColorId);
|
||||
return View(hairTaint);
|
||||
}
|
||||
|
||||
@ -73,6 +77,7 @@ namespace Yavsc.Controllers
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name",hairTaint.ColorId);
|
||||
return View(hairTaint);
|
||||
}
|
||||
|
||||
@ -87,6 +92,7 @@ namespace Yavsc.Controllers
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name", hairTaint.ColorId);
|
||||
return View(hairTaint);
|
||||
}
|
||||
|
||||
|
@ -2,14 +2,38 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Yavsc.Interfaces.Workflow;
|
||||
using Yavsc.Models.Market;
|
||||
using Yavsc.Models.Workflow;
|
||||
using YavscLib;
|
||||
|
||||
namespace Yavsc.Models.Billing
|
||||
{
|
||||
|
||||
public class NominativeServiceCommand<T> : Query<T> where T:Service
|
||||
public abstract class NominativeServiceCommand : IBaseTrackedEntity, IQuery
|
||||
{
|
||||
public DateTime DateCreated
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public DateTime DateModified
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string UserCreated
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string UserModified
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public QueryStatus Status { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ClientId { get; set; }
|
||||
|
14
Yavsc/Models/Haircut/HairCutQuery.cs
Normal file
14
Yavsc/Models/Haircut/HairCutQuery.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Yavsc.Models.Billing;
|
||||
|
||||
namespace Yavsc.Models.Haircut
|
||||
{
|
||||
public class HairCutQuery : NominativeServiceCommand
|
||||
{
|
||||
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public long Id { get; set; }
|
||||
HairPrestation [] Prestations { get; set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
namespace Yavsc.Models.Messaging
|
||||
namespace Yavsc.Models.Haircut
|
||||
{
|
||||
public class HairCutQueryEvent : BookQueryProviderInfo, IEvent
|
||||
{
|
||||
@ -27,5 +27,7 @@ namespace Yavsc.Models.Messaging
|
||||
|
||||
set;
|
||||
}
|
||||
|
||||
HairCutQuery Data { get; set; }
|
||||
}
|
||||
}
|
@ -1,13 +1,11 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Yavsc.Models.Market;
|
||||
|
||||
namespace Yavsc.Models.Haircut
|
||||
{
|
||||
public class HairPrestation
|
||||
public class HairPrestation : Service
|
||||
{
|
||||
[Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public long Id { get; set;}
|
||||
|
||||
public HairLength Length { get; set; }
|
||||
public HairCutGenders Gender { get; set; }
|
||||
public bool Cut { get; set; }
|
||||
|
@ -13,6 +13,9 @@ namespace Yavsc.Models.Haircut
|
||||
public string Brand { get; set; }
|
||||
|
||||
[Required]
|
||||
public Color Color {get; set;}
|
||||
public long ColorId { get; set; }
|
||||
|
||||
[ForeignKeyAttribute("ColorId")]
|
||||
public virtual Color Color {get; set;}
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ namespace Yavsc.Models.Workflow
|
||||
/// Query, for a date, with a given perfomer, at this given place.
|
||||
/// </summary>
|
||||
|
||||
public class BookQuery : NominativeServiceCommand<RendezVous>, IBaseTrackedEntity
|
||||
public class BookQuery : NominativeServiceCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// The command identifier
|
||||
|
@ -6,28 +6,8 @@ namespace Yavsc.Models.Workflow
|
||||
using Models.Market;
|
||||
using YavscLib;
|
||||
|
||||
public class Query<P>: IBaseTrackedEntity where P : BaseProduct
|
||||
public interface IQuery: IBaseTrackedEntity
|
||||
{
|
||||
public DateTime DateCreated
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public DateTime DateModified
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string UserCreated
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string UserModified
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
QueryStatus Status { get; set; }
|
||||
}
|
||||
|
||||
|
207
Yavsc/Views/Command/BookHaircutStar.cshtml
Normal file
207
Yavsc/Views/Command/BookHaircutStar.cshtml
Normal file
@ -0,0 +1,207 @@
|
||||
@model HairPrestationQuery
|
||||
@{ ViewData["Title"] = "Proposition de rendez-vous "+
|
||||
@SR["to"]+" "+ Model.PerformerProfile.Performer.UserName
|
||||
+" ["+SR[ViewBag.Activity.Code]+"]"; }
|
||||
|
||||
<script src="https://maps.googleapis.com/maps/api/js?key=@ViewBag.GoogleSettings.BrowserApiKey"></script>
|
||||
<script type="text/javascript" src="~/lib/moment/moment-with-locales.min.js"></script>
|
||||
<script type="text/javascript" src="~/lib/eonasdan-bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
|
||||
<link rel="stylesheet" href="~/lib/eonasdan-bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
|
||||
@section header {
|
||||
<style>
|
||||
#map {
|
||||
width: 100%;
|
||||
height: 250px;
|
||||
}
|
||||
#Location_combo li {
|
||||
cursor: pointer;
|
||||
}
|
||||
#Location_combo li:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
@section scripts{
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
|
||||
var config = {
|
||||
mapId: 'map',
|
||||
addrId: 'Location_Address',
|
||||
longId: 'Location_Longitude',
|
||||
latId: 'Location_Latitude',
|
||||
addrValidationId: 'valloc',
|
||||
formValidId: 'valsum',
|
||||
locComboId: 'loccomb'
|
||||
};
|
||||
|
||||
$.validator.setDefaults({
|
||||
messages: {
|
||||
remote: "Ce lieu n'est pas identifié par les services de géo-localisation Google",
|
||||
required: "Veuillez renseigner ce champ"
|
||||
}
|
||||
});
|
||||
var gmap = new google.maps.Map(document.getElementById(config.mapId), {
|
||||
zoom: 16,
|
||||
center: { lat: 48.862854, lng: 2.2056466 }
|
||||
});
|
||||
var marker;
|
||||
function chooseLoc(sender, loc) {
|
||||
if (sender === 'user') $('#' + config.addrId).val(loc.formatted_address);
|
||||
var pos = loc.geometry.location;
|
||||
var lat = new Number(pos.lat);
|
||||
var lng = new Number(pos.lng);
|
||||
$('#' + config.latId).val(lat.toLocaleString('fr'));
|
||||
$('#' + config.longId).val(lng.toLocaleString('fr'));
|
||||
gmap.setCenter(pos);
|
||||
if (marker) {
|
||||
marker.setMap(null);
|
||||
}
|
||||
marker = new google.maps.Marker({
|
||||
map: gmap,
|
||||
draggable: true,
|
||||
animation: google.maps.Animation.DROP,
|
||||
position: pos
|
||||
});
|
||||
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.addrId).valid();
|
||||
$('#' + config.addrValidationId).empty();
|
||||
$('#' + config.formValidId).empty();
|
||||
return true;
|
||||
}
|
||||
|
||||
$('#EventDate').datepicker({ language: 'fr' });
|
||||
|
||||
$('#' + config.addrId).rules("add",
|
||||
{
|
||||
remote: {
|
||||
url: 'https://maps.googleapis.com/maps/api/geocode/json',
|
||||
type: 'get',
|
||||
data: {
|
||||
sensor: false,
|
||||
address: function () { return $('#' + config.addrId).val() }
|
||||
},
|
||||
dataType: 'json',
|
||||
dataFilter: function (datastr, type) {
|
||||
$('#' + config.locComboId).html("");
|
||||
var data = JSON.parse(datastr);
|
||||
data.results.forEach(function (element) {
|
||||
if (element.formatted_address !== $('#' + config.addrId).val()) {
|
||||
$('<li>' + element.formatted_address + '</li>')
|
||||
.data("geoloc", element)
|
||||
.click(function () { chooseLoc('user', $(this).data("geoloc")) })
|
||||
.appendTo($('#' + config.locComboId));
|
||||
}
|
||||
else { }
|
||||
});
|
||||
if ((data.status === 'OK') && (data.results.length == 1)) {
|
||||
chooseLoc('google', data.results[0]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
console.log('ajax loading error ... ' + textStatus + ' ... ' + errorThrown);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
<h2>@ViewData["Title"]</h2>
|
||||
<form asp-action="Create" id="FrmComCre" role="form">
|
||||
<div class="form-horizontal">
|
||||
<h4>@SR["Fill in your book query"]</h4>
|
||||
<hr />
|
||||
<div asp-validation-summary="ValidationSummary.All" class="text-danger" id="valsum"></div>
|
||||
<div class="form-group" has-feedback>
|
||||
<fieldset>
|
||||
<legend>Votre évennement</legend>
|
||||
<label for="EventDate" class="col-md-2 control-label">
|
||||
@SR["Event date"]
|
||||
</label>
|
||||
<div class="col-md-10">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class='col-sm-6'>
|
||||
<div class='input-group date' id='datetimepicker2'>
|
||||
<input class="form-control" name="EventDate" />
|
||||
<span class="input-group-addon">
|
||||
<span class="glyphicon glyphicon-calendar"></span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$('#datetimepicker2').datetimepicker({
|
||||
locale: 'fr',
|
||||
format: "YYYY/MM/DD hh:mm"
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<span asp-validation-for="EventDate" class="text-danger">
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<label for="Location_Address" class="col-md-2 control-label">
|
||||
@SR["Location"]
|
||||
</label>
|
||||
<div class="col-md-10">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class='col-sm-6'>
|
||||
<div >
|
||||
<input asp-for="Location.Address" type="text" name="Location.Address" id="Location_Address" class="form-control" data-val-required=@SR[
|
||||
"SpecifyPlace"] data-val-remote=@SR[ "GoogleDidntGeoLocalized"]>
|
||||
<span asp-validation-for="Location.Address" class="text-danger" id="valloc"></span>
|
||||
<ul id="loccomb">
|
||||
</ul>
|
||||
<div id="map"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<label for="Reason" class="col-md-2 control-label">
|
||||
Ci-après, Vous pouvez ajouter des détails au sujet de vos souhaits
|
||||
concernant cette prestation
|
||||
</label>
|
||||
<div class="col-md-10">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class='col-sm-6'>
|
||||
<div id='reason1'>
|
||||
<textarea rows="15" asp-for="Reason" type="text" name="Reason" id="Reason" maxlength="4096" class="form-control"></textarea>
|
||||
<span asp-validation-for="Reason" class="text-danger"></span>
|
||||
@Html.HiddenFor(model=>model.Location.Latitude)
|
||||
@Html.HiddenFor(model=>model.Location.Longitude)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="@SR[" Create "]" class="btn btn-default" />
|
||||
</div>
|
||||
</div>
|
||||
@Html.HiddenFor(model=>model.ClientId)
|
||||
@Html.HiddenFor(model=>model.PerformerId)
|
||||
@Html.HiddenFor(model=>model.ActivityCode)
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
@ -1,5 +1,7 @@
|
||||
@model BookQuery
|
||||
@{ ViewData["Title"] = SR["Book "+ViewBag.Activity.Code]; }
|
||||
@{ ViewData["Title"] = "Proposition de rendez-vous "+
|
||||
@SR["to"]+" "+ Model.PerformerProfile.Performer.UserName
|
||||
+" ["+SR[ViewBag.Activity.Code]+"]"; }
|
||||
|
||||
<script src="https://maps.googleapis.com/maps/api/js?key=@ViewBag.GoogleSettings.BrowserApiKey"></script>
|
||||
<script type="text/javascript" src="~/lib/moment/moment-with-locales.min.js"></script>
|
||||
|
16
Yavsc/Views/FrontOffice/HArts.chtml
Normal file
16
Yavsc/Views/FrontOffice/HArts.chtml
Normal file
@ -0,0 +1,16 @@
|
||||
@model IEnumerable<PerformerProfile>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Book - " + (ViewBag.Activity?.Name ?? SR["Any"]);
|
||||
}
|
||||
<em>@ViewBag.Activity.Description</em>
|
||||
|
||||
@foreach (var profile in Model) {
|
||||
<hr/>
|
||||
@Html.DisplayFor(m=>m)
|
||||
<form action="~/Command/HArts" >
|
||||
<input type="hidden" name="id" value="@profile.PerformerId" />
|
||||
<input type="hidden" name="activityCode" value="@ViewBag.Activity.Code" />
|
||||
<input type="submit" value="@SR["Prennez un rendez-vous avec"] @profile.Performer.UserName"/>
|
||||
</form>
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
<form action="~/Command/Create" >
|
||||
<input type="hidden" name="id" value="@profile.PerformerId" />
|
||||
<input type="hidden" name="activityCode" value="@ViewBag.Activity.Code" />
|
||||
<input type="submit" value="@SR["Book "+ViewBag.Activity.Code]"/>
|
||||
<input type="submit" value="@SR["Proposer un rendez-vous à"] @profile.Performer.UserName"/>
|
||||
</form>
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,12 @@
|
||||
<span asp-validation-for="Brand" class="text-danger" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="ColorId" class="col-md-2 control-label"></label>
|
||||
<div class="col-md-10">
|
||||
<select asp-for="ColorId" asp-items=@ViewBag.ColorId class="form-control"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Create" class="btn btn-default" />
|
||||
|
@ -19,6 +19,13 @@
|
||||
<span asp-validation-for="Brand" class="text-danger" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="ColorId" class="control-label col-md-2">ColorId</label>
|
||||
<div class="col-md-10">
|
||||
<select asp-for="ColorId" asp-items=@ViewBag.ColorId class="form-control"></select>
|
||||
<span asp-validation-for="ColorId" class="text-danger" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Save" class="btn btn-default" />
|
||||
|
@ -14,6 +14,9 @@
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Brand)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.Color)
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
@ -22,6 +25,9 @@
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Brand)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Color)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
|
||||
<a asp-action="Details" asp-route-id="@item.Id">Details</a> |
|
||||
|
Reference in New Issue
Block a user