Gestion des activités

main
Paul Schneider 9 years ago
parent 48c9af0917
commit 6b683eb4af
22 changed files with 91 additions and 63 deletions

@ -13,11 +13,17 @@ namespace Yavsc.ApiControllers
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
using System.Security.Claims; using System.Security.Claims;
using Microsoft.Extensions.Localization;
using Yavsc.Services;
using Yavsc.Models.Messaging;
[Route("api/pdfestimate"), Authorize] [Route("api/pdfestimate"), Authorize]
public class PdfEstimateController : Controller public class PdfEstimateController : Controller
{ {
ApplicationDbContext dbContext; ApplicationDbContext dbContext;
private IStringLocalizer _localizer;
private GoogleAuthSettings _googleSettings;
private IGoogleCloudMessageSender _GCMSender;
private IAuthorizationService authorizationService; private IAuthorizationService authorizationService;
private ILogger logger; private ILogger logger;
@ -94,7 +100,11 @@ namespace Yavsc.ApiControllers
User.ReceiveSignature(id,Request.Form.Files[0],"pro"); User.ReceiveSignature(id,Request.Form.Files[0],"pro");
estimate.ProviderValidationDate = DateTime.Now; estimate.ProviderValidationDate = DateTime.Now;
dbContext.SaveChanges(); 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}")] [HttpPost("clisign/{id}")]

@ -3,9 +3,8 @@ using Microsoft.AspNet.Mvc;
namespace Yavsc.ApiControllers namespace Yavsc.ApiControllers
{ {
using Models; using Models;
using Models.Workflow;
[Produces("application/json"),Route("api/profile")] [Produces("application/json"),Route("api/profile")]
public abstract class ProfileApiController<T> : Controller where T : PerformerProfile public abstract class ProfileApiController<T> : Controller
{ {
ApplicationDbContext dbContext; ApplicationDbContext dbContext;
public ProfileApiController(ApplicationDbContext context) public ProfileApiController(ApplicationDbContext context)

@ -161,7 +161,6 @@ namespace Yavsc.Controllers
if (pro.Performer.Devices.Count > 0) { if (pro.Performer.Devices.Count > 0) {
var regids = command.PerformerProfile.Performer var regids = command.PerformerProfile.Performer
.Devices.Select(d => d.GCMRegistrationId); .Devices.Select(d => d.GCMRegistrationId);
var sregids = string.Join(",",regids);
grep = await _GCMSender.NotifyBookQueryAsync(_googleSettings,regids,yaev); grep = await _GCMSender.NotifyBookQueryAsync(_googleSettings,regids,yaev);
} }
// TODO setup a profile choice to allow notifications // TODO setup a profile choice to allow notifications

@ -19,8 +19,8 @@ namespace Yavsc.Controllers
_context = context; _context = context;
} }
// GET: Do // GET: /Do/Index
[HttpGet,ActionName("Index")] [HttpGet]
public IActionResult Index(string id) public IActionResult Index(string id)
{ {
if (id == null) if (id == null)

@ -11,8 +11,6 @@ using System;
namespace Yavsc.Controllers namespace Yavsc.Controllers
{ {
[ServiceFilter(typeof(LanguageActionFilter)),
Route("do")]
public class FrontOfficeController : Controller public class FrontOfficeController : Controller
{ {
ApplicationDbContext _context; ApplicationDbContext _context;
@ -42,17 +40,11 @@ namespace Yavsc.Controllers
{ {
throw new NotImplementedException("No Activity code"); throw new NotImplementedException("No Activity code");
} }
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 );
ViewBag.Activity = _context.Activities.FirstOrDefault( return View(result);
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
)
);
} }
[Route("Book/{id}"), HttpPost] [Route("Book/{id}"), HttpPost]

@ -110,11 +110,9 @@ namespace Yavsc.Controllers
DiskUsage = user.DiskUsage, DiskUsage = user.DiskUsage,
DiskQuota = user.DiskQuota DiskQuota = user.DiskQuota
}; };
if (_dbContext.Performers.Any(x => x.PerformerId == user.Id)) model.HaveProfessionalSettings = _dbContext.Performers.Any(x => x.PerformerId == user.Id);
{ model.Activity = _dbContext.UserActivities.Include(a=>a.Does).Where(u=>u.UserId == user.Id)
model.Activity = _dbContext.Performers.First(x => x.PerformerId == user.Id).Activity; .ToList();
}
return View(model); return View(model);
} }
@ -522,6 +520,7 @@ namespace Yavsc.Controllers
{ {
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
var exSiren = await _dbContext.ExceptionsSIREN.FirstOrDefaultAsync( var exSiren = await _dbContext.ExceptionsSIREN.FirstOrDefaultAsync(
ex => ex.SIREN == model.SIREN ex => ex.SIREN == model.SIREN
); );
@ -574,8 +573,8 @@ namespace Yavsc.Controllers
} }
else ModelState.AddModelError(string.Empty, $"Access denied ({uid} vs {model.PerformerId})"); else ModelState.AddModelError(string.Empty, $"Access denied ({uid} vs {model.PerformerId})");
} }
ViewBag.GoogleSettings = _googleSettings; ViewBag.GoogleSettings = _googleSettings;
ViewBag.Activities = _dbContext.ActivityItems(model.Activity);
return View(model); return View(model);
} }

@ -34,6 +34,7 @@ namespace Yavsc.Models
builder.Entity<GoogleCloudMobileDeclaration>().Property(x=>x.DeclarationDate).HasDefaultValueSql("LOCALTIMESTAMP"); builder.Entity<GoogleCloudMobileDeclaration>().Property(x=>x.DeclarationDate).HasDefaultValueSql("LOCALTIMESTAMP");
builder.Entity<PostTag>().HasKey(x=>new { x.PostId, x.TagId}); builder.Entity<PostTag>().HasKey(x=>new { x.PostId, x.TagId});
builder.Entity<ApplicationUser>().HasMany<Connection>( c=>c.Connections ); builder.Entity<ApplicationUser>().HasMany<Connection>( c=>c.Connections );
builder.Entity<UserActivity>().HasKey(u=> new { u.DoesCode, u.UserId});
} }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

@ -9,6 +9,8 @@ namespace Yavsc.Models.Billing
{ {
using Interfaces; using Interfaces;
using Models.Booking; using Models.Booking;
using Yavsc.Models.Workflow;
public partial class Estimate : IEstimate public partial class Estimate : IEstimate
{ {
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
@ -61,8 +63,13 @@ namespace Yavsc.Models.Billing
[Required] [Required]
public string OwnerId { get; set; } public string OwnerId { get; set; }
[ForeignKey("OwnerId")]
public virtual PerformerProfile Owner { get; set; }
[Required] [Required]
public string ClientId { get; set; } public string ClientId { get; set; }
[ForeignKey("ClientId")]
public virtual ApplicationUser Client { get; set; }
public string CommandType public string CommandType
{ {

@ -4,7 +4,7 @@ using Yavsc.Models.Workflow;
namespace Yavsc.Models.Booking namespace Yavsc.Models.Booking
{ {
public class DjPerformerProfile : PerformerProfile public class DjPerformerProfile : SpecializationSettings
{ {
public string SoundCloudId { get; set; } public string SoundCloudId { get; set; }

@ -13,7 +13,7 @@ namespace Yavsc.Models.Workflow
public virtual ApplicationUser Performer { get; set; } public virtual ApplicationUser Performer { get; set; }
[InverseProperty("User")] [InverseProperty("User")]
[Display(Name="Activity"),Required] [Display(Name="Activity")]
public virtual List<UserActivity> Activity { get; set; } public virtual List<UserActivity> Activity { get; set; }
[Required,StringLength(14),Display(Name="SIREN"), [Required,StringLength(14),Display(Name="SIREN"),

@ -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; }
}
}

@ -299,6 +299,8 @@
<data name="Profile edition"><value>Édition du profile</value></data> <data name="Profile edition"><value>Édition du profile</value></data>
<data name="Product reference"><value>Référence produit</value></data> <data name="Product reference"><value>Référence produit</value></data>
<data name="prestation"><value>prestation</value></data> <data name="prestation"><value>prestation</value></data>
<data name="Professional settings"><value>Paramètres professionels</value></data>
<data name="ProviderId"><value>Identifiant du fournisseur</value></data> <data name="ProviderId"><value>Identifiant du fournisseur</value></data>
<data name="ProviderName"><value>Nom du fournisseur</value></data> <data name="ProviderName"><value>Nom du fournisseur</value></data>
<data name="Rate"><value>Cote</value></data> <data name="Rate"><value>Cote</value></data>
@ -376,8 +378,8 @@
<data name="YourNeed"><value>Votre besoin</value></data> <data name="YourNeed"><value>Votre besoin</value></data>
<data name="yourquerytransmitted"><value>Votre demande a été transmise</value></data> <data name="yourquerytransmitted"><value>Votre demande a été transmise</value></data>
<data name="YourSkills"><value>Vos talents, vos spécialités, le domaine de vos activités</value></data> <data name="YourSkills"><value>Vos talents, vos spécialités, le domaine de vos activités</value></data>
<data name="YourPosts"><value>Vos publications</value></data> <data name="Your posts"><value>Vos publications</value></data>
<data name="YourProfile"><value>Votre profile</value></data> <data name="Your profile"><value>Votre profile</value></data>
<data name="YourMessageHasBeenSent"><value>Votre messge a été envoyé</value></data> <data name="YourMessageHasBeenSent"><value>Votre messge a été envoyé</value></data>
<data name="Tell more, below, about your query"><value>Dites en plus, ci àprès, à propos de cet évennement</value></data> <data name="Tell more, below, about your query"><value>Dites en plus, ci àprès, à propos de cet évennement</value></data>

@ -95,8 +95,8 @@ namespace Yavsc
}; };
var supportedUICultures = new[] var supportedUICultures = new[]
{ {
new CultureInfo("en"), new CultureInfo("fr"),
new CultureInfo("fr") new CultureInfo("en")
}; };
// You must explicitly state which cultures your application supports. // You must explicitly state which cultures your application supports.

@ -24,6 +24,8 @@ namespace Yavsc.ViewModels.Manage
public List<UserActivity> Activity { get; set; } public List<UserActivity> Activity { get; set; }
public bool HaveProfessionalSettings { get; set; }
public long PostsCounter { get; set; } public long PostsCounter { get; set; }
public AccountBalance Balance { get; set; } public AccountBalance Balance { get; set; }

@ -17,7 +17,7 @@
@foreach (var item in Model) { @foreach (var item in Model) {
<tr> <tr>
<td> @Html.Display("item.Name") <td> @item.Does.Name
</td> </td>
<td> <td>
<a asp-action="Edit" asp-route-id="@item.Id">Edit</a> | <a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |

@ -6,7 +6,8 @@
<em>@ViewBag.Activity.Description</em> <em>@ViewBag.Activity.Description</em>
@foreach (var profile in Model) { @foreach (var profile in Model) {
await Html.RenderPartialAsync("_PerformerPartial", profile) ; <hr/>
await Html.RenderPartialAsync("PerformerProfile", profile) ;
<form action="~/Command/Create" > <form action="~/Command/Create" >
<input type="hidden" name="id" value="@profile.PerformerId" /> <input type="hidden" name="id" value="@profile.PerformerId" />
<input type="submit" value="@SR["Book "+ViewBag.Activity.Code]"/> <input type="submit" value="@SR["Book "+ViewBag.Activity.Code]"/>

@ -1,8 +1,7 @@
@{ @{
ViewData["Title"] = "Index"; ViewData["Title"] = "Front office";
} }
<h2>Index</h2> <h2>Index</h2>

@ -16,7 +16,7 @@
<p> <p>
Invitez un groupe musical à animer votre événement </p> Invitez un groupe musical à animer votre événement </p>
<p> <p>
<a class="btn btn-default" href="~/do/Book/IT"> <a class="btn btn-default" asp-controller="FrontOffice" asp-action="Book" asp-route-id="IT">
En savoir plus En savoir plus
</a> </a>
</p> </p>
@ -28,7 +28,7 @@
<p> <p>
Organisez un concert. </p> Organisez un concert. </p>
<p> <p>
<a class="btn btn-default" href="~/do/Book/IT"> <a class="btn btn-default" asp-controller="FrontOffice" asp-action="Book" asp-route-id="IT">
En savoir plus En savoir plus
</a> </a>
</p> </p>
@ -40,7 +40,7 @@
<p> Offrez-vous un anniversaire, un mariage Hip Hop </p> <p> Offrez-vous un anniversaire, un mariage Hip Hop </p>
<p> <p>
<a class="btn btn-default" href="~/do/Book/IT"> <a class="btn btn-default" asp-controller="FrontOffice" asp-action="Book" asp-route-id="IT">
En savoir plus En savoir plus
</a> </a>
@ -53,7 +53,7 @@
<p> <p>
Invitez votre chanteur à la fête </p> Invitez votre chanteur à la fête </p>
<p> <p>
<a class="btn btn-default" href="~/do/Book/IT"> <a class="btn btn-default" asp-controller="FrontOffice" asp-route-id="Book" >
En savoir plus En savoir plus
</a> </a>
</p> </p>

@ -1,4 +1,5 @@
@model IndexViewModel @model IndexViewModel
@using System.Security.Claims
@{ @{
ViewData["Title"] = @SR["Manage your account"]; ViewData["Title"] = @SR["Manage your account"];
} }
@ -53,21 +54,27 @@
>@SR[@Model.Avatar==null?"Set":"Modify"]</a>] >@SR[@Model.Avatar==null?"Set":"Modify"]</a>]
</dd> </dd>
<dt>@SR["Activity"]:</dt> <dt>@SR["Professional settings"]:</dt>
<dd>@Html.DisplayFor(model => model.Activity) <dd>
@Html.DisplayFor(model => model.HaveProfessionalSettings)
[<a asp-controller="Manage" asp-action="SetActivity" [<a asp-controller="Manage" asp-action="SetActivity"
>@SR[Model.HaveProfessionalSettings?"Modify settings":"Set"]</a>]
</dd>
@if (Model.HaveProfessionalSettings) {
<dt>@SR["Activities"]:</dt>
<dd>
@string.Join(", ",Model.Activity.Select( u=> u.Does.Name ).ToArray())
[<a asp-controller="Do" asp-action="Index"
>@SR[@Model.Activity==null?"Set":"Modify settings"]</a>] >@SR[@Model.Activity==null?"Set":"Modify settings"]</a>]
</dd> </dd>
}
<dt>@SR["Bank info"]:</dt> <dt>@SR["Bank info"]:</dt>
<dd>@Html.DisplayFor(m => m.BankInfo) [<a asp-controller="Manage" asp-action="AddBankInfo" <dd>@Html.DisplayFor(m => m.BankInfo) [<a asp-controller="Manage" asp-action="AddBankInfo"
>@SR[@Model.BankInfo==null?"Set":"Modify"]</a>]</dd> >@SR[@Model.BankInfo==null?"Set":"Modify"]</a>]</dd>
<dt>@SR["YourPosts"]:</dt> <dt><a asp-controller="Blogspot" asp-action="UserPosts"
<dd>@Model.PostsCounter asp-route-id="@Model.UserName">@SR["Your posts"]:</a></dt>
[<a asp-controller="Blogspot" asp-action="UserPosts" <dd>@Model.PostsCounter</dd>
asp-route-id="@Model.UserName">@SR["YourPosts"]</a>]
</dd>
<dt>@SR["TwoFactorAuthentication"]:</dt> <dt>@SR["TwoFactorAuthentication"]:</dt>
<dd> <dd>
@ -114,6 +121,10 @@
@(Model.DiskUsage.ToString("0,#")) / @(Model.DiskQuota.ToString("0,#")) @(Model.DiskUsage.ToString("0,#")) / @(Model.DiskQuota.ToString("0,#"))
</text> </text>
</dd> </dd>
<dt>Identifiant utilisateur</dt>
<dd>
@User.GetUserId()
</dd>
</dl> </dl>
<h4> <h4>
<a asp-controller="Account" asp-action="Delete" >@SR["Unregister"]</a> <a asp-controller="Account" asp-action="Delete" >@SR["Unregister"]</a>

@ -105,22 +105,13 @@
} }
<h2>@ViewData["Title"].</h2> <h2>@ViewData["Title"].</h2>
@{ await Html.RenderPartialAsync("_PerformerPartial", Model) ; } @Html.DisplayFor(model => model)
<form id="FrmSetAct" asp-controller="Manage" asp-action="SetActivity" method="post" class="form-horizontal" role="form"> <form id="FrmSetAct" asp-controller="Manage" asp-action="SetActivity" method="post" class="form-horizontal" role="form">
<h4>@SR["Choose below your main activity"]:</h4> <h4>@SR["Choose below your main activity"]:</h4>
<hr /> <hr />
<div asp-validation-summary="ValidationSummary.All" class="text-danger" id="valsum"></div> <div asp-validation-summary="ValidationSummary.All" class="text-danger" id="valsum"></div>
<div class="form-group">
<label asp-for="Activity" class="col-md-2 control-label"></label>
<div class="col-md-10">
<select asp-for="Activity" asp-items=@ViewBag.Activities class="form-control" multiple>
</select>
<span asp-validation-for="Activity" class="text-danger"></span>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label asp-for="AcceptNotifications" class="col-md-2 control-label"></label> <label asp-for="AcceptNotifications" class="col-md-2 control-label"></label>
<div class="col-md-10"> <div class="col-md-10">

@ -37,6 +37,6 @@
} }
</ul> </ul>
<button id="btnAddUser">Ajouter aux contacts</button>
} }
</div> </div>
Loading…