en preparant le badge "activité à configurer!"

This commit is contained in:
2017-03-03 17:36:29 +01:00
parent b6c39c0ce8
commit 071660cf89
16 changed files with 78 additions and 20 deletions

View File

@ -78,16 +78,16 @@ namespace Yavsc.Controllers
public async Task<IActionResult> Index(ManageMessageId? message = null)
{
ViewData["StatusMessage"] =
message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
: message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
: message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set."
: message == ManageMessageId.Error ? "An error has occurred."
: message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added."
: message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
: message == ManageMessageId.ChangeNameSuccess ? "Your name was updated."
: message == ManageMessageId.SetActivitySuccess ? "Your activity was set."
: message == ManageMessageId.AvatarUpdateSuccess ? "Your avatar was updated."
: message == ManageMessageId.IdentityUpdateSuccess ? "Your identity was updated."
message == ManageMessageId.ChangePasswordSuccess ? _SR["Your password has been changed."]
: message == ManageMessageId.SetPasswordSuccess ? _SR["Your password has been set."]
: message == ManageMessageId.SetTwoFactorSuccess ? _SR["Your two-factor authentication provider has been set."]
: message == ManageMessageId.Error ? _SR["An error has occurred."]
: message == ManageMessageId.AddPhoneSuccess ? _SR["Your phone number was added."]
: message == ManageMessageId.RemovePhoneSuccess ? _SR["Your phone number was removed."]
: message == ManageMessageId.ChangeNameSuccess ? _SR["Your name was updated."]
: message == ManageMessageId.SetActivitySuccess ? _SR["Your activity was set."]
: message == ManageMessageId.AvatarUpdateSuccess ? _SR["Your avatar was updated."]
: message == ManageMessageId.IdentityUpdateSuccess ? _SR["Your identity was updated."]
: "";
var user = await GetCurrentUserAsync();
@ -114,6 +114,13 @@ namespace Yavsc.Controllers
DiskQuota = user.DiskQuota
};
model.HaveProfessionalSettings = _dbContext.Performers.Any(x => x.PerformerId == user.Id);
var usrActs = _dbContext.UserActivities.Include(a=>a.Does).Where(a=> a.UserId == user.Id);
await usrActs.Where(u=>u.Does.SettingsClassName!=null).ForEachAsync(
a=>{ a.Settings = a.Does.CreateSettings(User.GetUserId()); }
);
model.HaveActivityToConfigure = usrActs.Any( a=> a.Settings == null && a.Does.SettingsClassName!=null );
model.Activity = _dbContext.UserActivities.Include(a=>a.Does).Where(u=>u.UserId == user.Id)
.ToList();
return View(model);

View File

@ -10,13 +10,18 @@ namespace Yavsc.Helpers
using YavscLib;
public static class WorkflowHelpers
{
public static ISpecializationSettings CreateSettings (this Activity activity) {
public static ISpecializationSettings CreateSettings (this Activity activity, string userId) {
if (activity.SettingsClassName==null) return null;
var ctor = Startup.ProfileTypes[activity.SettingsClassName].GetConstructor(System.Type.EmptyTypes);
if (ctor==null) return null;
return (ISpecializationSettings) ctor.Invoke(null);
ISpecializationSettings result = (ISpecializationSettings) ctor.Invoke(null);
result.UserId = userId;
return result;
}
public static bool HasSettings (this UserActivity useract, ApplicationDbContext dbContext) {
ISpecializationSettings candidate = CreateSettings(useract.Does,useract.UserId);
return candidate.ExistsInDb(dbContext);
}
public static List<PerformerProfile> ListPerformers(this ApplicationDbContext context, string actCode)
{
return context.Performers

View File

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System.Linq;
using YavscLib;
namespace Yavsc.Models.Haircut
@ -135,5 +136,10 @@ namespace Yavsc.Models.Haircut
[Display(Name="Remise au forfait coupe+technique"),DisplayFormat(DataFormatString="{0:C}")]
public decimal FlatFeeDiscount { get; set; }
public bool ExistsInDb(object dbContext)
{
return ((ApplicationDbContext)dbContext).BrusherProfile.Any(p=>p.UserId==UserId);
}
}
}

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using YavscLib;
namespace Yavsc.Models.Musical.Profiles
@ -17,5 +18,9 @@ namespace Yavsc.Models.Musical.Profiles
get; set;
}
public bool ExistsInDb(object dbContext)
{
return ((ApplicationDbContext)dbContext).DjSettings.Any(p=>p.UserId==UserId);
}
}
}

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using YavscLib;
namespace Yavsc.Models.Musical.Profiles
@ -12,5 +13,10 @@ namespace Yavsc.Models.Musical.Profiles
{
get; set;
}
public bool ExistsInDb(object dbContext)
{
return ((ApplicationDbContext)dbContext).GeneralSettings.Any(p=>p.UserId==UserId);
}
}
}

View File

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using Yavsc.Models.Workflow;
using YavscLib;
@ -18,5 +19,9 @@ namespace Yavsc.Models.Musical.Profiles
[ForeignKeyAttribute("InstrumentId")]
public virtual Instrument Tool { get; set; }
public bool ExistsInDb(object dbContext)
{
return ((ApplicationDbContext)dbContext).Instrumentation.Any(p=>p.UserId==UserId);
}
}
}

View File

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
namespace Yavsc.Models.Workflow.Profiles
{
using System.Linq;
using Models.Workflow;
using YavscLib;
public class FormationSettings : ISpecializationSettings
@ -14,5 +15,10 @@ namespace Yavsc.Models.Workflow.Profiles
{
get; set;
}
public bool ExistsInDb(object dbContext)
{
return ((ApplicationDbContext)dbContext).FormationSettings.Any(p=>p.UserId==UserId);
}
}
}

View File

@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
namespace Yavsc.Models.Workflow
{
@ -19,5 +20,8 @@ namespace Yavsc.Models.Workflow
[Range(0,100)]
public int Weight { get; set; }
[NotMapped,JsonIgnore]
public object Settings { get; internal set; }
}
}

View File

@ -25,6 +25,7 @@ namespace Yavsc.ViewModels.Manage
public List<UserActivity> Activity { get; set; }
public bool HaveProfessionalSettings { get; set; }
public bool HaveActivityToConfigure { get; set; }
public long PostsCounter { get; set; }

View File

@ -18,7 +18,7 @@
<input type="hidden" asp-for="DoesCode" />
<div class="form-actions no-color">
<input type="submit" value="Delete" class="btn btn-success" />
<a asp-action="Index" class="btn btn-default">Back to List</a>
<a asp-action="Index" class="btn btn-link">Back to List</a>
</div>
</form>
</div>

View File

@ -114,8 +114,20 @@ Paul,
</environment>
<environment names="Dev">
<environment names="Development">
<markdown>
Site du développeur
## Ceci est un site de développement.
Cette présente ressource ne concerne que le développement du logiciel qui la met en oeuvre.
Elle est éphémère, et pratiquement en permanence force de codes 500.
Veuillez excuser l'équipe de développement pour vous avoir fait part de cette adresse et pour la gêne occasionnnée.
La "pré-production" affiche les sites suivants:
* [ZicMoove](http://zicmoove.pschneider.fr)
* [Yavsc](http://yavsc.pschneider.fr)
* [Lua (le site perso de l'auteur de ce truc)](http://lua.pschneider.fr)
</markdown>
</environment>

View File

@ -104,7 +104,7 @@ nav {
data-ref="ZicMoove"
class="fb-like"
data-share="true"
data-width="200"
data-width="300"
data-show-faces="true"
data-colorscheme="dark">
</div>

File diff suppressed because one or more lines are too long

View File

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

View File

@ -3,5 +3,6 @@ namespace YavscLib
public interface ISpecializationSettings
{
string UserId { get ; set ; }
bool ExistsInDb(object dbContext);
}
}