From cea0defaf47000f8c338d1eebaa675b5f243dbc6 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 13 Feb 2017 01:32:03 +0100 Subject: [PATCH] refact --- Yavsc/Controllers/FrontOfficeController.cs | 6 +- Yavsc/Controllers/HairTaintsController.cs | 14 +- ...Command.cs => NominativeServiceCommand.cs} | 26 ++- Yavsc/Models/Haircut/HairCutQuery.cs | 14 ++ Yavsc/Models/Haircut/HairCutQueryEvent.cs | 4 +- Yavsc/Models/Haircut/HairPrestation.cs | 6 +- Yavsc/Models/Haircut/HairTaint.cs | 5 +- Yavsc/Models/Workflow/BookQuery.cs | 2 +- Yavsc/Models/Workflow/Query.cs | 22 +- Yavsc/Views/Command/BookHaircutStar.cshtml | 207 ++++++++++++++++++ Yavsc/Views/Command/Create.cshtml | 4 +- Yavsc/Views/FrontOffice/HArts.chtml | 16 ++ Yavsc/Views/FrontOffice/Profiles.cshtml | 2 +- Yavsc/Views/HairTaints/Create.cshtml | 6 + Yavsc/Views/HairTaints/Edit.cshtml | 7 + Yavsc/Views/HairTaints/Index.cshtml | 6 + 16 files changed, 309 insertions(+), 38 deletions(-) rename Yavsc/Models/Billing/{NominatvieCommand.cs => NominativeServiceCommand.cs} (62%) create mode 100644 Yavsc/Models/Haircut/HairCutQuery.cs create mode 100644 Yavsc/Views/Command/BookHaircutStar.cshtml create mode 100644 Yavsc/Views/FrontOffice/HArts.chtml diff --git a/Yavsc/Controllers/FrontOfficeController.cs b/Yavsc/Controllers/FrontOfficeController.cs index db4720dfe..282d64bbb 100644 --- a/Yavsc/Controllers/FrontOfficeController.cs +++ b/Yavsc/Controllers/FrontOfficeController.cs @@ -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 )); diff --git a/Yavsc/Controllers/HairTaintsController.cs b/Yavsc/Controllers/HairTaintsController.cs index 33edfc18e..49bf9502e 100644 --- a/Yavsc/Controllers/HairTaintsController.cs +++ b/Yavsc/Controllers/HairTaintsController.cs @@ -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 { @@ -14,13 +15,14 @@ namespace Yavsc.Controllers public HairTaintsController(ApplicationDbContext context) { - _context = context; + _context = context; } // GET: HairTaints public async Task 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); } diff --git a/Yavsc/Models/Billing/NominatvieCommand.cs b/Yavsc/Models/Billing/NominativeServiceCommand.cs similarity index 62% rename from Yavsc/Models/Billing/NominatvieCommand.cs rename to Yavsc/Models/Billing/NominativeServiceCommand.cs index 8c2bb0313..e824acf69 100644 --- a/Yavsc/Models/Billing/NominatvieCommand.cs +++ b/Yavsc/Models/Billing/NominativeServiceCommand.cs @@ -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 : Query 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; } diff --git a/Yavsc/Models/Haircut/HairCutQuery.cs b/Yavsc/Models/Haircut/HairCutQuery.cs new file mode 100644 index 000000000..1464f0ee6 --- /dev/null +++ b/Yavsc/Models/Haircut/HairCutQuery.cs @@ -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; } + } +} \ No newline at end of file diff --git a/Yavsc/Models/Haircut/HairCutQueryEvent.cs b/Yavsc/Models/Haircut/HairCutQueryEvent.cs index 6077945bf..900b7b6ee 100644 --- a/Yavsc/Models/Haircut/HairCutQueryEvent.cs +++ b/Yavsc/Models/Haircut/HairCutQueryEvent.cs @@ -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; } } } \ No newline at end of file diff --git a/Yavsc/Models/Haircut/HairPrestation.cs b/Yavsc/Models/Haircut/HairPrestation.cs index 351d66bb7..e38254204 100644 --- a/Yavsc/Models/Haircut/HairPrestation.cs +++ b/Yavsc/Models/Haircut/HairPrestation.cs @@ -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; } diff --git a/Yavsc/Models/Haircut/HairTaint.cs b/Yavsc/Models/Haircut/HairTaint.cs index 9026fb19a..09c1cec00 100644 --- a/Yavsc/Models/Haircut/HairTaint.cs +++ b/Yavsc/Models/Haircut/HairTaint.cs @@ -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;} } } \ No newline at end of file diff --git a/Yavsc/Models/Workflow/BookQuery.cs b/Yavsc/Models/Workflow/BookQuery.cs index 11dd3a1b1..9f7edec7e 100644 --- a/Yavsc/Models/Workflow/BookQuery.cs +++ b/Yavsc/Models/Workflow/BookQuery.cs @@ -12,7 +12,7 @@ namespace Yavsc.Models.Workflow /// Query, for a date, with a given perfomer, at this given place. /// - public class BookQuery : NominativeServiceCommand, IBaseTrackedEntity + public class BookQuery : NominativeServiceCommand { /// /// The command identifier diff --git a/Yavsc/Models/Workflow/Query.cs b/Yavsc/Models/Workflow/Query.cs index 369bb3005..c619f78bc 100644 --- a/Yavsc/Models/Workflow/Query.cs +++ b/Yavsc/Models/Workflow/Query.cs @@ -6,28 +6,8 @@ namespace Yavsc.Models.Workflow using Models.Market; using YavscLib; - public class Query

: 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; } } diff --git a/Yavsc/Views/Command/BookHaircutStar.cshtml b/Yavsc/Views/Command/BookHaircutStar.cshtml new file mode 100644 index 000000000..9e631dc3e --- /dev/null +++ b/Yavsc/Views/Command/BookHaircutStar.cshtml @@ -0,0 +1,207 @@ +@model HairPrestationQuery +@{ ViewData["Title"] = "Proposition de rendez-vous "+ +@SR["to"]+" "+ Model.PerformerProfile.Performer.UserName ++" ["+SR[ViewBag.Activity.Code]+"]"; } + + + + + +@section header { + +} +@section scripts{ + +} +

@ViewData["Title"]

+
+
+

@SR["Fill in your book query"]

+
+
+
+
+ Votre évennement + +
+
+
+
+
+ + + + +
+
+ + + +
+
+
+ +
+
+
+
+
+ + +
    +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+ + +@Html.HiddenFor(model=>model.Location.Latitude) + @Html.HiddenFor(model=>model.Location.Longitude) +
+
+
+
+
+
+
+
+
+ +
+
+@Html.HiddenFor(model=>model.ClientId) +@Html.HiddenFor(model=>model.PerformerId) +@Html.HiddenFor(model=>model.ActivityCode) +
+ + +
+ +@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } diff --git a/Yavsc/Views/Command/Create.cshtml b/Yavsc/Views/Command/Create.cshtml index cdb9d8c54..dc385204c 100644 --- a/Yavsc/Views/Command/Create.cshtml +++ b/Yavsc/Views/Command/Create.cshtml @@ -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]+"]"; } diff --git a/Yavsc/Views/FrontOffice/HArts.chtml b/Yavsc/Views/FrontOffice/HArts.chtml new file mode 100644 index 000000000..dadf80345 --- /dev/null +++ b/Yavsc/Views/FrontOffice/HArts.chtml @@ -0,0 +1,16 @@ +@model IEnumerable + +@{ + ViewData["Title"] = "Book - " + (ViewBag.Activity?.Name ?? SR["Any"]); +} +@ViewBag.Activity.Description + +@foreach (var profile in Model) { +
+ @Html.DisplayFor(m=>m) +
+ + + +
+} diff --git a/Yavsc/Views/FrontOffice/Profiles.cshtml b/Yavsc/Views/FrontOffice/Profiles.cshtml index ee399d0ab..88ed7d0e7 100644 --- a/Yavsc/Views/FrontOffice/Profiles.cshtml +++ b/Yavsc/Views/FrontOffice/Profiles.cshtml @@ -11,7 +11,7 @@
- +
} diff --git a/Yavsc/Views/HairTaints/Create.cshtml b/Yavsc/Views/HairTaints/Create.cshtml index d758783e5..0c9210ecd 100644 --- a/Yavsc/Views/HairTaints/Create.cshtml +++ b/Yavsc/Views/HairTaints/Create.cshtml @@ -18,6 +18,12 @@ +
+ +
+ +
+
diff --git a/Yavsc/Views/HairTaints/Edit.cshtml b/Yavsc/Views/HairTaints/Edit.cshtml index 5e0ab9aa6..0b7d68b2f 100644 --- a/Yavsc/Views/HairTaints/Edit.cshtml +++ b/Yavsc/Views/HairTaints/Edit.cshtml @@ -19,6 +19,13 @@
+
+ +
+ + +
+
diff --git a/Yavsc/Views/HairTaints/Index.cshtml b/Yavsc/Views/HairTaints/Index.cshtml index 358094f58..5a02d5cb4 100644 --- a/Yavsc/Views/HairTaints/Index.cshtml +++ b/Yavsc/Views/HairTaints/Index.cshtml @@ -14,6 +14,9 @@ @Html.DisplayNameFor(model => model.Brand) + + @Html.DisplayNameFor(model => model.Color) + @@ -22,6 +25,9 @@ @Html.DisplayFor(modelItem => item.Brand) + + @Html.DisplayFor(modelItem => item.Color) + Edit | Details |