From 8b6dac72e0d7d93f629a7808b5924c7d102c502c Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 2 Aug 2016 11:03:06 +0200 Subject: [PATCH] lister ses commandes en tant que presta ou client --- Yavsc/Controllers/CommandController.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Yavsc/Controllers/CommandController.cs b/Yavsc/Controllers/CommandController.cs index 7883f195..fe2a4277 100644 --- a/Yavsc/Controllers/CommandController.cs +++ b/Yavsc/Controllers/CommandController.cs @@ -51,14 +51,18 @@ namespace Yavsc.Controllers } // GET: Command + [Authorize] public IActionResult Index() { + var uid = User.GetUserId(); return View(_context.BookQueries .Include(x => x.Client) .Include(x => x.PerformerProfile) .Include(x => x.PerformerProfile.Performer) .Include(x => x.Location) - .Include(x => x.Bill).ToList()); + .Include(x => x.Bill) + .Where(x=> x.ClientId == uid || x.PerformerId == uid) + .ToList()); } // GET: Command/Details/5 @@ -138,13 +142,19 @@ namespace Yavsc.Controllers command.Client = user; if (ModelState.IsValid) { - var yaev = command.CreateEvent(_localizer); - MessageWithPayloadResponse grep = null; + var existingLocation = _context.Locations.FirstOrDefault( x=>x.Address == command.Location.Address + && x.Longitude == command.Location.Longitude && x.Latitude == command.Location.Latitude ); - _context.Attach(command.Location); + if (existingLocation!=null) { + command.Location=existingLocation; + } + else _context.Attach(command.Location); _context.BookQueries.Add(command, GraphBehavior.IncludeDependents); _context.SaveChanges(); + var yaev = command.CreateEvent(_localizer); + MessageWithPayloadResponse grep = null; + if (pro.AcceptNotifications && pro.AcceptPublicContact) {