From 6b683eb4aff10154428b34066e104daddb51c9b4 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 9 Jan 2017 16:29:34 +0100 Subject: [PATCH] =?UTF-8?q?Gestion=20des=20activit=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Yavsc/ApiControllers/PdfEstimateController.cs | 12 ++++++++- Yavsc/ApiControllers/ProfileApiController.cs | 3 +-- Yavsc/Controllers/CommandController.cs | 1 - Yavsc/Controllers/DoController.cs | 4 +-- Yavsc/Controllers/FrontOfficeController.cs | 18 ++++--------- Yavsc/Controllers/ManageController.cs | 11 ++++---- Yavsc/Helpers/EventHelpers.cs | 2 +- Yavsc/Models/ApplicationDbContext.cs | 1 + Yavsc/Models/Billing/Estimate.cs | 7 +++++ .../Booking/Profiles/DjPerformerProfile.cs | 2 +- Yavsc/Models/Workflow/PerformerProfile.cs | 2 +- Yavsc/Models/Workflow/Specialization.cs | 15 +++++++++++ .../Yavsc.Resources.YavscLocalisation.fr.resx | 6 +++-- Yavsc/Startup/Startup.cs | 6 ++--- Yavsc/ViewModels/Manage/IndexViewModel.cs | 2 ++ Yavsc/Views/Do/Index.cshtml | 2 +- Yavsc/Views/FrontOffice/Book.cshtml | 7 ++--- Yavsc/Views/FrontOffice/Index.cshtml | 3 +-- Yavsc/Views/Home/Index.cshtml | 8 +++--- Yavsc/Views/Manage/Index.cshtml | 27 +++++++++++++------ Yavsc/Views/Manage/SetActivity.cshtml | 13 ++------- ...Partial.cshtml => PerformerProfile.cshtml} | 2 +- 22 files changed, 91 insertions(+), 63 deletions(-) create mode 100644 Yavsc/Models/Workflow/Specialization.cs rename Yavsc/Views/Shared/{_PerformerPartial.cshtml => PerformerProfile.cshtml} (95%) diff --git a/Yavsc/ApiControllers/PdfEstimateController.cs b/Yavsc/ApiControllers/PdfEstimateController.cs index d6c10abd..e871ba68 100644 --- a/Yavsc/ApiControllers/PdfEstimateController.cs +++ b/Yavsc/ApiControllers/PdfEstimateController.cs @@ -13,11 +13,17 @@ namespace Yavsc.ApiControllers using Microsoft.Extensions.Logging; using System; using System.Security.Claims; + using Microsoft.Extensions.Localization; + using Yavsc.Services; + using Yavsc.Models.Messaging; [Route("api/pdfestimate"), Authorize] public class PdfEstimateController : Controller { ApplicationDbContext dbContext; + private IStringLocalizer _localizer; + private GoogleAuthSettings _googleSettings; + private IGoogleCloudMessageSender _GCMSender; private IAuthorizationService authorizationService; private ILogger logger; @@ -94,7 +100,11 @@ namespace Yavsc.ApiControllers User.ReceiveSignature(id,Request.Form.Files[0],"pro"); estimate.ProviderValidationDate = DateTime.Now; dbContext.SaveChanges(); - return Ok (new { ProviderValidationDate = estimate.ProviderValidationDate }); + // Notify the client + var yaev = new EstimationEvent(dbContext,estimate,_localizer); + var regids = estimate.Client.Devices.Select(d => d.GCMRegistrationId); + var grep = await _GCMSender.NotifyEstimateAsync(_googleSettings,regids,yaev); + return Ok (new { ProviderValidationDate = estimate.ProviderValidationDate, GCMSent = grep.success }); } [HttpPost("clisign/{id}")] diff --git a/Yavsc/ApiControllers/ProfileApiController.cs b/Yavsc/ApiControllers/ProfileApiController.cs index 5309454c..77426afa 100644 --- a/Yavsc/ApiControllers/ProfileApiController.cs +++ b/Yavsc/ApiControllers/ProfileApiController.cs @@ -3,9 +3,8 @@ using Microsoft.AspNet.Mvc; namespace Yavsc.ApiControllers { using Models; - using Models.Workflow; [Produces("application/json"),Route("api/profile")] - public abstract class ProfileApiController : Controller where T : PerformerProfile + public abstract class ProfileApiController : Controller { ApplicationDbContext dbContext; public ProfileApiController(ApplicationDbContext context) diff --git a/Yavsc/Controllers/CommandController.cs b/Yavsc/Controllers/CommandController.cs index 77b14420..4b2a2d62 100644 --- a/Yavsc/Controllers/CommandController.cs +++ b/Yavsc/Controllers/CommandController.cs @@ -161,7 +161,6 @@ namespace Yavsc.Controllers if (pro.Performer.Devices.Count > 0) { var regids = command.PerformerProfile.Performer .Devices.Select(d => d.GCMRegistrationId); - var sregids = string.Join(",",regids); grep = await _GCMSender.NotifyBookQueryAsync(_googleSettings,regids,yaev); } // TODO setup a profile choice to allow notifications diff --git a/Yavsc/Controllers/DoController.cs b/Yavsc/Controllers/DoController.cs index 0318efa5..98634289 100644 --- a/Yavsc/Controllers/DoController.cs +++ b/Yavsc/Controllers/DoController.cs @@ -19,8 +19,8 @@ namespace Yavsc.Controllers _context = context; } - // GET: Do - [HttpGet,ActionName("Index")] + // GET: /Do/Index + [HttpGet] public IActionResult Index(string id) { if (id == null) diff --git a/Yavsc/Controllers/FrontOfficeController.cs b/Yavsc/Controllers/FrontOfficeController.cs index 3fb75ace..c895a8c9 100644 --- a/Yavsc/Controllers/FrontOfficeController.cs +++ b/Yavsc/Controllers/FrontOfficeController.cs @@ -11,8 +11,6 @@ using System; namespace Yavsc.Controllers { - [ServiceFilter(typeof(LanguageActionFilter)), - Route("do")] public class FrontOfficeController : Controller { ApplicationDbContext _context; @@ -42,17 +40,11 @@ namespace Yavsc.Controllers { throw new NotImplementedException("No Activity code"); } - - ViewBag.Activity = _context.Activities.FirstOrDefault( - a => a.Code == id); - - return View( - _context.Performers.Include(p => p.Performer) - .Include(p=>p.Performer.Devices).Where - (p => p.Activity.Any( a => a.DoesCode == id) && p.Active).OrderBy( - x => x.MinDailyCost - ) - ); + ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == id); + var result = _context.Performers + .Include(p=>p.Performer).Where(p => p.Activity.Any(u=>u.DoesCode==id)).OrderBy( x => x.MinDailyCost ); + + return View(result); } [Route("Book/{id}"), HttpPost] diff --git a/Yavsc/Controllers/ManageController.cs b/Yavsc/Controllers/ManageController.cs index 64f6092e..b04a8fa0 100644 --- a/Yavsc/Controllers/ManageController.cs +++ b/Yavsc/Controllers/ManageController.cs @@ -110,11 +110,9 @@ namespace Yavsc.Controllers DiskUsage = user.DiskUsage, DiskQuota = user.DiskQuota }; - if (_dbContext.Performers.Any(x => x.PerformerId == user.Id)) - { - model.Activity = _dbContext.Performers.First(x => x.PerformerId == user.Id).Activity; - - } + model.HaveProfessionalSettings = _dbContext.Performers.Any(x => x.PerformerId == user.Id); + model.Activity = _dbContext.UserActivities.Include(a=>a.Does).Where(u=>u.UserId == user.Id) + .ToList(); return View(model); } @@ -522,6 +520,7 @@ namespace Yavsc.Controllers { if (ModelState.IsValid) { + var exSiren = await _dbContext.ExceptionsSIREN.FirstOrDefaultAsync( ex => ex.SIREN == model.SIREN ); @@ -574,8 +573,8 @@ namespace Yavsc.Controllers } else ModelState.AddModelError(string.Empty, $"Access denied ({uid} vs {model.PerformerId})"); } + ViewBag.GoogleSettings = _googleSettings; - ViewBag.Activities = _dbContext.ActivityItems(model.Activity); return View(model); } diff --git a/Yavsc/Helpers/EventHelpers.cs b/Yavsc/Helpers/EventHelpers.cs index 1461c495..f65d352b 100644 --- a/Yavsc/Helpers/EventHelpers.cs +++ b/Yavsc/Helpers/EventHelpers.cs @@ -23,6 +23,6 @@ namespace Yavsc.Helpers }; return yaev; } - + } } diff --git a/Yavsc/Models/ApplicationDbContext.cs b/Yavsc/Models/ApplicationDbContext.cs index 26d9ec2e..804ce1a4 100644 --- a/Yavsc/Models/ApplicationDbContext.cs +++ b/Yavsc/Models/ApplicationDbContext.cs @@ -34,6 +34,7 @@ namespace Yavsc.Models builder.Entity().Property(x=>x.DeclarationDate).HasDefaultValueSql("LOCALTIMESTAMP"); builder.Entity().HasKey(x=>new { x.PostId, x.TagId}); builder.Entity().HasMany( c=>c.Connections ); + builder.Entity().HasKey(u=> new { u.DoesCode, u.UserId}); } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) diff --git a/Yavsc/Models/Billing/Estimate.cs b/Yavsc/Models/Billing/Estimate.cs index e60e60b5..de70da41 100644 --- a/Yavsc/Models/Billing/Estimate.cs +++ b/Yavsc/Models/Billing/Estimate.cs @@ -9,6 +9,8 @@ namespace Yavsc.Models.Billing { using Interfaces; using Models.Booking; + using Yavsc.Models.Workflow; + public partial class Estimate : IEstimate { [Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)] @@ -61,8 +63,13 @@ namespace Yavsc.Models.Billing [Required] public string OwnerId { get; set; } + [ForeignKey("OwnerId")] + public virtual PerformerProfile Owner { get; set; } + [Required] public string ClientId { get; set; } + [ForeignKey("ClientId")] + public virtual ApplicationUser Client { get; set; } public string CommandType { diff --git a/Yavsc/Models/Booking/Profiles/DjPerformerProfile.cs b/Yavsc/Models/Booking/Profiles/DjPerformerProfile.cs index c1e2617d..18613e15 100644 --- a/Yavsc/Models/Booking/Profiles/DjPerformerProfile.cs +++ b/Yavsc/Models/Booking/Profiles/DjPerformerProfile.cs @@ -4,7 +4,7 @@ using Yavsc.Models.Workflow; namespace Yavsc.Models.Booking { - public class DjPerformerProfile : PerformerProfile + public class DjPerformerProfile : SpecializationSettings { public string SoundCloudId { get; set; } diff --git a/Yavsc/Models/Workflow/PerformerProfile.cs b/Yavsc/Models/Workflow/PerformerProfile.cs index f004221b..516a21c4 100644 --- a/Yavsc/Models/Workflow/PerformerProfile.cs +++ b/Yavsc/Models/Workflow/PerformerProfile.cs @@ -13,7 +13,7 @@ namespace Yavsc.Models.Workflow public virtual ApplicationUser Performer { get; set; } [InverseProperty("User")] - [Display(Name="Activity"),Required] + [Display(Name="Activity")] public virtual List Activity { get; set; } [Required,StringLength(14),Display(Name="SIREN"), diff --git a/Yavsc/Models/Workflow/Specialization.cs b/Yavsc/Models/Workflow/Specialization.cs new file mode 100644 index 00000000..47b2773b --- /dev/null +++ b/Yavsc/Models/Workflow/Specialization.cs @@ -0,0 +1,15 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Yavsc.Models.Workflow +{ + public abstract class SpecializationSettings + { + [Key] + public long UserActivityId { get; set; } + + [ForeignKey("UserActivityId")] + public virtual UserActivity Context { get; set; } + + } +} \ No newline at end of file diff --git a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx index 6616b385..5cbdb395 100644 --- a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx +++ b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx @@ -299,6 +299,8 @@ Édition du profile Référence produit prestation + Paramètres professionels + Identifiant du fournisseur Nom du fournisseur Cote @@ -376,8 +378,8 @@ Votre besoin Votre demande a été transmise Vos talents, vos spécialités, le domaine de vos activités - Vos publications - Votre profile + Vos publications + Votre profile Votre messge a été envoyé Dites en plus, ci àprès, à propos de cet évennement diff --git a/Yavsc/Startup/Startup.cs b/Yavsc/Startup/Startup.cs index 5620051e..524a65c7 100755 --- a/Yavsc/Startup/Startup.cs +++ b/Yavsc/Startup/Startup.cs @@ -95,8 +95,8 @@ namespace Yavsc }; var supportedUICultures = new[] { - new CultureInfo("en"), - new CultureInfo("fr") + new CultureInfo("fr"), + new CultureInfo("en") }; // You must explicitly state which cultures your application supports. @@ -335,7 +335,7 @@ namespace Yavsc ConfigureFileServerApp(app, siteSettings.Value, env, authorizationService); ConfigureWebSocketsApp(app, siteSettings.Value, env); - app.UseRequestLocalization(localizationOptions.Value, (RequestCulture)new RequestCulture((string)"en")); + app.UseRequestLocalization(localizationOptions.Value, (RequestCulture) new RequestCulture((string)"en")); app.UseMvc(routes => { diff --git a/Yavsc/ViewModels/Manage/IndexViewModel.cs b/Yavsc/ViewModels/Manage/IndexViewModel.cs index 3fd49818..b9ae1619 100644 --- a/Yavsc/ViewModels/Manage/IndexViewModel.cs +++ b/Yavsc/ViewModels/Manage/IndexViewModel.cs @@ -24,6 +24,8 @@ namespace Yavsc.ViewModels.Manage public List Activity { get; set; } + public bool HaveProfessionalSettings { get; set; } + public long PostsCounter { get; set; } public AccountBalance Balance { get; set; } diff --git a/Yavsc/Views/Do/Index.cshtml b/Yavsc/Views/Do/Index.cshtml index b784e532..5c9c7269 100644 --- a/Yavsc/Views/Do/Index.cshtml +++ b/Yavsc/Views/Do/Index.cshtml @@ -17,7 +17,7 @@ @foreach (var item in Model) { - @Html.Display("item.Name") + @item.Does.Name Edit | diff --git a/Yavsc/Views/FrontOffice/Book.cshtml b/Yavsc/Views/FrontOffice/Book.cshtml index d0a421bf..6f77f910 100644 --- a/Yavsc/Views/FrontOffice/Book.cshtml +++ b/Yavsc/Views/FrontOffice/Book.cshtml @@ -6,9 +6,10 @@ @ViewBag.Activity.Description @foreach (var profile in Model) { - await Html.RenderPartialAsync("_PerformerPartial", profile) ; +
+ await Html.RenderPartialAsync("PerformerProfile", profile) ;
- -
+ + } diff --git a/Yavsc/Views/FrontOffice/Index.cshtml b/Yavsc/Views/FrontOffice/Index.cshtml index 8ebf00fa..dd9ee17d 100644 --- a/Yavsc/Views/FrontOffice/Index.cshtml +++ b/Yavsc/Views/FrontOffice/Index.cshtml @@ -1,8 +1,7 @@ @{ - ViewData["Title"] = "Index"; + ViewData["Title"] = "Front office"; }

Index

- diff --git a/Yavsc/Views/Home/Index.cshtml b/Yavsc/Views/Home/Index.cshtml index dd32853d..cf2d8089 100755 --- a/Yavsc/Views/Home/Index.cshtml +++ b/Yavsc/Views/Home/Index.cshtml @@ -16,7 +16,7 @@

Invitez un groupe musical à animer votre événement

- + En savoir plus

@@ -28,7 +28,7 @@

Organisez un concert.

- + En savoir plus

@@ -40,7 +40,7 @@

Offrez-vous un anniversaire, un mariage Hip Hop

- + En savoir plus @@ -53,7 +53,7 @@

Invitez votre chanteur à la fête

- + En savoir plus

diff --git a/Yavsc/Views/Manage/Index.cshtml b/Yavsc/Views/Manage/Index.cshtml index ba0d9f39..54a594fd 100755 --- a/Yavsc/Views/Manage/Index.cshtml +++ b/Yavsc/Views/Manage/Index.cshtml @@ -1,4 +1,5 @@ @model IndexViewModel +@using System.Security.Claims @{ ViewData["Title"] = @SR["Manage your account"]; } @@ -53,21 +54,27 @@ >@SR[@Model.Avatar==null?"Set":"Modify"]] -
@SR["Activity"]:
-
@Html.DisplayFor(model => model.Activity) +
@SR["Professional settings"]:
+
+ @Html.DisplayFor(model => model.HaveProfessionalSettings) [@SR[Model.HaveProfessionalSettings?"Modify settings":"Set"]] +
+@if (Model.HaveProfessionalSettings) { +
@SR["Activities"]:
+
+ @string.Join(", ",Model.Activity.Select( u=> u.Does.Name ).ToArray()) + [@SR[@Model.Activity==null?"Set":"Modify settings"]]
- +}
@SR["Bank info"]:
@Html.DisplayFor(m => m.BankInfo) [@SR[@Model.BankInfo==null?"Set":"Modify"]]
-
@SR["YourPosts"]:
-
@Model.PostsCounter - [@SR["YourPosts"]] -
+
@SR["Your posts"]:
+
@Model.PostsCounter
@SR["TwoFactorAuthentication"]:
@@ -114,6 +121,10 @@ @(Model.DiskUsage.ToString("0,#")) / @(Model.DiskQuota.ToString("0,#"))
+
Identifiant utilisateur
+
+ @User.GetUserId() +

@SR["Unregister"] diff --git a/Yavsc/Views/Manage/SetActivity.cshtml b/Yavsc/Views/Manage/SetActivity.cshtml index 154c1662..24da0af2 100644 --- a/Yavsc/Views/Manage/SetActivity.cshtml +++ b/Yavsc/Views/Manage/SetActivity.cshtml @@ -105,22 +105,13 @@ }

@ViewData["Title"].

-@{ await Html.RenderPartialAsync("_PerformerPartial", Model) ; } +@Html.DisplayFor(model => model)

@SR["Choose below your main activity"]:


-
- -
- - - -
-
+
diff --git a/Yavsc/Views/Shared/_PerformerPartial.cshtml b/Yavsc/Views/Shared/PerformerProfile.cshtml similarity index 95% rename from Yavsc/Views/Shared/_PerformerPartial.cshtml rename to Yavsc/Views/Shared/PerformerProfile.cshtml index b245a5d2..dccb92aa 100644 --- a/Yavsc/Views/Shared/_PerformerPartial.cshtml +++ b/Yavsc/Views/Shared/PerformerProfile.cshtml @@ -37,6 +37,6 @@ } - + }