Paul Schneider 8 years ago
commit 4dc4a40988
21 changed files with 1278 additions and 25 deletions

@ -144,7 +144,7 @@ namespace Yavsc.WebApi.Controllers
/// <param name="me">MyUpdate containing the new user name </param>
/// <returns>Ok when all is ok.</returns>
[HttpPut("~/api/me")]
public async Task<IActionResult> UpdateMe(MyUpdate me)
public async Task<IActionResult> UpdateMe(UserInfo me)
{
if (!ModelState.IsValid) return new BadRequestObjectResult(
new { error = "Specify some valid user update request." });

@ -47,7 +47,8 @@ namespace Yavsc.Controllers
Location = c.Location,
EventDate = c.EventDate,
Id = c.Id,
Previsional = c.Previsional
Previsional = c.Previsional,
Reason = c.Reason
}).
OrderBy(c=>c.Id).
Take(25);

@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
@ -7,7 +6,10 @@ using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity;
using Yavsc.Models;
using Yavsc.Models.Auth;
using Yavsc.ViewModels.Administration;
namespace Yavsc.Controllers
{
@ -17,11 +19,15 @@ namespace Yavsc.Controllers
private readonly UserManager<ApplicationUser> _userManager;
private readonly RoleManager<IdentityRole> _roleManager;
private readonly ApplicationDbContext context;
public AdministrationController(UserManager<ApplicationUser> userManager,
RoleManager<IdentityRole> roleManager)
RoleManager<IdentityRole> roleManager,
ApplicationDbContext context)
{
_userManager = userManager;
_roleManager = roleManager;
this.context = context;
}
/// <summary>
@ -47,30 +53,53 @@ namespace Yavsc.Controllers
AddErrors(addToRoleResult);
return new BadRequestObjectResult(ModelState);
}
return Ok(new {message="you owned it."});
}
public class RoleInfo {
public string Name { get; set; }
public IEnumerable<string> Users { get; set; }
return Ok(new { message = "you owned it." });
}
[Authorize(Roles=Constants.AdminGroupName)]
[Authorize(Roles = Constants.AdminGroupName)]
[Produces("application/json")]
public async Task<IActionResult> Index() {
public async Task<IActionResult> Index()
{
var adminCount = await _userManager.GetUsersInRoleAsync(
Constants.AdminGroupName);
var youAreAdmin = await _userManager.IsInRoleAsync(
await _userManager.FindByIdAsync(User.GetUserId()),
Constants.AdminGroupName);
var roles = _roleManager.Roles.Select(x=>
new RoleInfo {
Name = x.Name,
Users = x.Users.Select( u=>u.UserId )
} );
return Ok (new { Roles = roles, AdminCount = adminCount.Count,
YouAreAdmin = youAreAdmin
var roles = _roleManager.Roles.Include(
x => x.Users
).Select(x => new RoleInfo {
Id = x.Id,
Name = x.Name,
Users = x.Users.Select(u=>u.UserId).ToArray()
});
return View(new AdminViewModel
{
Roles = roles.ToArray(),
AdminCount = adminCount.Count,
YouAreAdmin = youAreAdmin
});
}
public IActionResult Role(string id)
{
IdentityRole role = _roleManager.Roles
.Include(r=>r.Users).FirstOrDefault
( r=> r.Id == id );
var ri = GetRoleUserCollection(role);
return View("Role",ri);
}
public RoleUserCollection GetRoleUserCollection(IdentityRole role)
{
var result = new RoleUserCollection {
Id = role.Id,
Name = role.Name,
Users = context.Users.Where(u=>role.Users.Any(ru => u.Id == ru.UserId))
.Select( u => new UserInfo { UserName = u.UserName, Avatar = u.Avatar, UserId = u.Id } )
.ToArray()
};
return result;
}
private void AddErrors(IdentityResult result)
{
foreach (var error in result.Errors)

@ -48,7 +48,8 @@ namespace Yavsc.Controllers
a => a.Code == id);
return View(
_context.Performers.Include(p => p.Performer).Where
_context.Performers.Include(p => p.Performer)
.Include(p=>p.Performer.Devices).Where
(p => p.ActivityCode == id && p.Active).OrderBy(
x => x.MinDailyCost
)

@ -0,0 +1,838 @@
using System;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Migrations;
using Yavsc.Models;
namespace Yavsc.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20161209121035_bookQueryReason")]
partial class bookQueryReason
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
modelBuilder
.HasAnnotation("ProductVersion", "7.0.0-rc1-16348");
modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRole", b =>
{
b.Property<string>("Id");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasAnnotation("MaxLength", 256);
b.Property<string>("NormalizedName")
.HasAnnotation("MaxLength", 256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.HasAnnotation("Relational:Name", "RoleNameIndex");
b.HasAnnotation("Relational:TableName", "AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasAnnotation("Relational:TableName", "AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasAnnotation("Relational:TableName", "AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasAnnotation("Relational:TableName", "AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasAnnotation("Relational:TableName", "AspNetUserRoles");
});
modelBuilder.Entity("Yavsc.Location", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Address")
.IsRequired()
.HasAnnotation("MaxLength", 512);
b.Property<double>("Latitude");
b.Property<double>("Longitude");
b.HasKey("Id");
});
modelBuilder.Entity("Yavsc.Model.Bank.BankIdentity", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("AccountNumber")
.HasAnnotation("MaxLength", 15);
b.Property<string>("BIC")
.HasAnnotation("MaxLength", 15);
b.Property<string>("BankCode")
.HasAnnotation("MaxLength", 5);
b.Property<int>("BankedKey");
b.Property<string>("IBAN")
.HasAnnotation("MaxLength", 33);
b.Property<string>("WicketCode")
.HasAnnotation("MaxLength", 5);
b.HasKey("Id");
});
modelBuilder.Entity("Yavsc.Model.Chat.Connection", b =>
{
b.Property<string>("ConnectionId");
b.Property<string>("ApplicationUserId");
b.Property<bool>("Connected");
b.Property<string>("UserAgent");
b.HasKey("ConnectionId");
});
modelBuilder.Entity("Yavsc.Model.ClientProviderInfo", b =>
{
b.Property<string>("UserId");
b.Property<string>("Avatar");
b.Property<long?>("BillingAddressId");
b.Property<string>("ChatHubConnectionId");
b.Property<string>("EMail");
b.Property<string>("Phone");
b.Property<int>("Rate");
b.Property<string>("UserName");
b.HasKey("UserId");
});
modelBuilder.Entity("Yavsc.Models.AccountBalance", b =>
{
b.Property<string>("UserId");
b.Property<long>("ContactCredits");
b.Property<decimal>("Credits");
b.HasKey("UserId");
});
modelBuilder.Entity("Yavsc.Models.Activity", b =>
{
b.Property<string>("Code")
.HasAnnotation("MaxLength", 512);
b.Property<string>("ActorDenomination");
b.Property<string>("Description");
b.Property<string>("ModeratorGroupName");
b.Property<string>("Name")
.IsRequired()
.HasAnnotation("MaxLength", 512);
b.Property<string>("Photo");
b.HasKey("Code");
});
modelBuilder.Entity("Yavsc.Models.ApplicationUser", b =>
{
b.Property<string>("Id");
b.Property<int>("AccessFailedCount");
b.Property<string>("Avatar")
.HasAnnotation("MaxLength", 512);
b.Property<long?>("BankInfoId");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("DedicatedGoogleCalendar");
b.Property<long>("DiskQuota");
b.Property<long>("DiskUsage");
b.Property<string>("Email")
.HasAnnotation("MaxLength", 256);
b.Property<bool>("EmailConfirmed");
b.Property<string>("FullName")
.HasAnnotation("MaxLength", 512);
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasAnnotation("MaxLength", 256);
b.Property<string>("NormalizedUserName")
.HasAnnotation("MaxLength", 256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<long?>("PostalAddressId");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasAnnotation("MaxLength", 256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasAnnotation("Relational:Name", "EmailIndex");
b.HasIndex("NormalizedUserName")
.HasAnnotation("Relational:Name", "UserNameIndex");
b.HasAnnotation("Relational:TableName", "AspNetUsers");
});
modelBuilder.Entity("Yavsc.Models.Auth.Client", b =>
{
b.Property<string>("Id");
b.Property<bool>("Active");
b.Property<string>("DisplayName");
b.Property<string>("LogoutRedirectUri")
.HasAnnotation("MaxLength", 100);
b.Property<string>("RedirectUri");
b.Property<int>("RefreshTokenLifeTime");
b.Property<string>("Secret");
b.Property<int>("Type");
b.HasKey("Id");
});
modelBuilder.Entity("Yavsc.Models.Auth.RefreshToken", b =>
{
b.Property<string>("Id");
b.Property<string>("ClientId")
.IsRequired()
.HasAnnotation("MaxLength", 50);
b.Property<DateTime>("ExpiresUtc");
b.Property<DateTime>("IssuedUtc");
b.Property<string>("ProtectedTicket")
.IsRequired();
b.Property<string>("Subject")
.IsRequired()
.HasAnnotation("MaxLength", 50);
b.HasKey("Id");
});
modelBuilder.Entity("Yavsc.Models.BalanceImpact", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("BalanceId")
.IsRequired();
b.Property<DateTime>("ExecDate");
b.Property<decimal>("Impact");
b.Property<string>("Reason")
.IsRequired();
b.HasKey("Id");
});
modelBuilder.Entity("Yavsc.Models.Billing.CommandLine", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<long?>("ArticleId");
b.Property<int>("Count");
b.Property<string>("Description")
.IsRequired()
.HasAnnotation("MaxLength", 512);
b.Property<long>("EstimateId");
b.Property<long?>("EstimateTemplateId");
b.Property<decimal>("UnitaryCost");
b.HasKey("Id");
});
modelBuilder.Entity("Yavsc.Models.Billing.Estimate", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("AttachedFilesString");
b.Property<string>("AttachedGraphicsString");
b.Property<string>("ClientId")
.IsRequired();
b.Property<DateTime>("ClientValidationDate");
b.Property<long?>("CommandId");
b.Property<string>("CommandType");
b.Property<string>("Description");
b.Property<string>("OwnerId")
.IsRequired();
b.Property<DateTime>("ProviderValidationDate");
b.Property<string>("Title");
b.HasKey("Id");
});
modelBuilder.Entity("Yavsc.Models.Billing.EstimateTemplate", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Description");
b.Property<string>("OwnerId")
.IsRequired();
b.Property<string>("Title");
b.HasKey("Id");
});
modelBuilder.Entity("Yavsc.Models.Billing.ExceptionSIREN", b =>
{
b.Property<string>("SIREN");
b.HasKey("SIREN");
});
modelBuilder.Entity("Yavsc.Models.Blog", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("AuthorId");
b.Property<string>("Content");
b.Property<DateTime>("Modified");
b.Property<string>("Photo");
b.Property<DateTime>("Posted")
.ValueGeneratedOnAdd()
.HasAnnotation("Relational:GeneratedValueSql", "LOCALTIMESTAMP");
b.Property<int>("Rate");
b.Property<string>("Title");
b.Property<bool>("Visible");
b.HasKey("Id");
});
modelBuilder.Entity("Yavsc.Models.Booking.BookQuery", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClientId")
.IsRequired();
b.Property<DateTime>("CreationDate")
.ValueGeneratedOnAdd()
.HasAnnotation("Relational:GeneratedValueSql", "LOCALTIMESTAMP");
b.Property<DateTime>("EventDate");
b.Property<long?>("LocationId");
b.Property<string>("PerformerId")
.IsRequired();
b.Property<decimal?>("Previsional");
b.Property<string>("Reason");
b.Property<DateTime?>("ValidationDate");
b.HasKey("Id");
});
modelBuilder.Entity("Yavsc.Models.Circle", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ApplicationUserId");
b.Property<string>("Name");
b.Property<string>("OwnerId");
b.HasKey("Id");
});
modelBuilder.Entity("Yavsc.Models.CircleMember", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<long>("CircleId");
b.Property<string>("MemberId")
.IsRequired();
b.HasKey("Id");
});
modelBuilder.Entity("Yavsc.Models.Contact", b =>
{
b.Property<string>("OwnerId");
b.Property<string>("UserId");
b.Property<string>("ApplicationUserId");
b.HasKey("OwnerId", "UserId");
});
modelBuilder.Entity("Yavsc.Models.Identity.GoogleCloudMobileDeclaration", b =>
{
b.Property<string>("DeviceId");
b.Property<DateTime>("DeclarationDate")
.ValueGeneratedOnAdd()
.HasAnnotation("Relational:GeneratedValueSql", "LOCALTIMESTAMP");
b.Property<string>("DeviceOwnerId");
b.Property<string>("GCMRegistrationId")
.IsRequired();
b.Property<string>("Model");
b.Property<string>("Platform");
b.Property<string>("Version");
b.HasKey("DeviceId");
});
modelBuilder.Entity("Yavsc.Models.Market.BaseProduct", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Description");
b.Property<string>("Discriminator")
.IsRequired();
b.Property<string>("Name");
b.Property<bool>("Public");
b.HasKey("Id");
b.HasAnnotation("Relational:DiscriminatorProperty", "Discriminator");
b.HasAnnotation("Relational:DiscriminatorValue", "BaseProduct");
});
modelBuilder.Entity("Yavsc.Models.Market.Service", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ContextId");
b.Property<string>("Description");
b.Property<string>("Name");
b.Property<bool>("Public");
b.HasKey("Id");
});
modelBuilder.Entity("Yavsc.Models.OAuth.OAuth2Tokens", b =>
{
b.Property<string>("UserId");
b.Property<string>("AccessToken");
b.Property<DateTime>("Expiration");
b.Property<string>("ExpiresIn");
b.Property<string>("RefreshToken");
b.Property<string>("TokenType");
b.HasKey("UserId");
});
modelBuilder.Entity("Yavsc.Models.PostTag", b =>
{
b.Property<long>("PostId");
b.Property<long>("TagId");
b.HasKey("PostId", "TagId");
});
modelBuilder.Entity("Yavsc.Models.Skill", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
b.Property<int>("Rate");
b.HasKey("Id");
});
modelBuilder.Entity("Yavsc.Models.Tag", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name")
.IsRequired();
b.HasKey("Id");
});
modelBuilder.Entity("Yavsc.Models.Workflow.PerformerProfile", b =>
{
b.Property<string>("PerformerId");
b.Property<bool>("AcceptGeoLocalization");
b.Property<bool>("AcceptNotifications");
b.Property<bool>("AcceptPublicContact");
b.Property<bool>("Active");
b.Property<string>("ActivityCode")
.IsRequired();
b.Property<int?>("MaxDailyCost");
b.Property<int?>("MinDailyCost");
b.Property<long?>("OfferId");
b.Property<long>("OrganizationAddressId");
b.Property<int>("Rate");
b.Property<string>("SIREN")
.IsRequired()
.HasAnnotation("MaxLength", 14);
b.Property<string>("WebSite");
b.HasKey("PerformerId");
});
modelBuilder.Entity("Yavsc.Models.Market.Product", b =>
{
b.HasBaseType("Yavsc.Models.Market.BaseProduct");
b.Property<decimal>("Depth");
b.Property<decimal>("Height");
b.Property<decimal?>("Price");
b.Property<decimal>("Weight");
b.Property<decimal>("Width");
b.HasAnnotation("Relational:DiscriminatorValue", "Product");
});
modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNet.Identity.EntityFramework.IdentityRole")
.WithMany()
.HasForeignKey("RoleId");
});
modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserClaim<string>", b =>
{
b.HasOne("Yavsc.Models.ApplicationUser")
.WithMany()
.HasForeignKey("UserId");
});
modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserLogin<string>", b =>
{
b.HasOne("Yavsc.Models.ApplicationUser")
.WithMany()
.HasForeignKey("UserId");
});
modelBuilder.Entity("Microsoft.AspNet.Identity.EntityFramework.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNet.Identity.EntityFramework.IdentityRole")
.WithMany()
.HasForeignKey("RoleId");
b.HasOne("Yavsc.Models.ApplicationUser")
.WithMany()
.HasForeignKey("UserId");
});
modelBuilder.Entity("Yavsc.Model.Chat.Connection", b =>
{
b.HasOne("Yavsc.Models.ApplicationUser")
.WithMany()
.HasForeignKey("ApplicationUserId");
});
modelBuilder.Entity("Yavsc.Model.ClientProviderInfo", b =>
{
b.HasOne("Yavsc.Location")
.WithMany()
.HasForeignKey("BillingAddressId");
});
modelBuilder.Entity("Yavsc.Models.AccountBalance", b =>
{
b.HasOne("Yavsc.Models.ApplicationUser")
.WithOne()
.HasForeignKey("Yavsc.Models.AccountBalance", "UserId");
});
modelBuilder.Entity("Yavsc.Models.ApplicationUser", b =>
{
b.HasOne("Yavsc.Model.Bank.BankIdentity")
.WithMany()
.HasForeignKey("BankInfoId");
b.HasOne("Yavsc.Location")
.WithMany()
.HasForeignKey("PostalAddressId");
});
modelBuilder.Entity("Yavsc.Models.BalanceImpact", b =>
{
b.HasOne("Yavsc.Models.AccountBalance")
.WithMany()
.HasForeignKey("BalanceId");
});
modelBuilder.Entity("Yavsc.Models.Billing.CommandLine", b =>
{
b.HasOne("Yavsc.Models.Market.BaseProduct")
.WithMany()
.HasForeignKey("ArticleId");
b.HasOne("Yavsc.Models.Billing.Estimate")
.WithMany()
.HasForeignKey("EstimateId");
b.HasOne("Yavsc.Models.Billing.EstimateTemplate")
.WithMany()
.HasForeignKey("EstimateTemplateId");
});
modelBuilder.Entity("Yavsc.Models.Billing.Estimate", b =>
{
b.HasOne("Yavsc.Models.Booking.BookQuery")
.WithMany()
.HasForeignKey("CommandId");
});
modelBuilder.Entity("Yavsc.Models.Blog", b =>
{
b.HasOne("Yavsc.Models.ApplicationUser")
.WithMany()
.HasForeignKey("AuthorId");
});
modelBuilder.Entity("Yavsc.Models.Booking.BookQuery", b =>
{
b.HasOne("Yavsc.Models.ApplicationUser")
.WithMany()
.HasForeignKey("ClientId");
b.HasOne("Yavsc.Location")
.WithMany()
.HasForeignKey("LocationId");
b.HasOne("Yavsc.Models.Workflow.PerformerProfile")
.WithMany()
.HasForeignKey("PerformerId");
});
modelBuilder.Entity("Yavsc.Models.Circle", b =>
{
b.HasOne("Yavsc.Models.ApplicationUser")
.WithMany()
.HasForeignKey("ApplicationUserId");
});
modelBuilder.Entity("Yavsc.Models.CircleMember", b =>
{
b.HasOne("Yavsc.Models.Circle")
.WithMany()
.HasForeignKey("CircleId");
b.HasOne("Yavsc.Models.ApplicationUser")
.WithMany()
.HasForeignKey("MemberId");
});
modelBuilder.Entity("Yavsc.Models.Contact", b =>
{
b.HasOne("Yavsc.Models.ApplicationUser")
.WithMany()
.HasForeignKey("ApplicationUserId");
});
modelBuilder.Entity("Yavsc.Models.Identity.GoogleCloudMobileDeclaration", b =>
{
b.HasOne("Yavsc.Models.ApplicationUser")
.WithMany()
.HasForeignKey("DeviceOwnerId");
});
modelBuilder.Entity("Yavsc.Models.Market.Service", b =>
{
b.HasOne("Yavsc.Models.Activity")
.WithMany()
.HasForeignKey("ContextId");
});
modelBuilder.Entity("Yavsc.Models.PostTag", b =>
{
b.HasOne("Yavsc.Models.Blog")
.WithMany()
.HasForeignKey("PostId");
});
modelBuilder.Entity("Yavsc.Models.Workflow.PerformerProfile", b =>
{
b.HasOne("Yavsc.Models.Activity")
.WithMany()
.HasForeignKey("ActivityCode");
b.HasOne("Yavsc.Models.Market.Service")
.WithMany()
.HasForeignKey("OfferId");
b.HasOne("Yavsc.Location")
.WithMany()
.HasForeignKey("OrganizationAddressId");
b.HasOne("Yavsc.Models.ApplicationUser")
.WithMany()
.HasForeignKey("PerformerId");
});
}
}
}

@ -0,0 +1,276 @@
using Microsoft.Data.Entity.Migrations;
namespace Yavsc.Migrations
{
public partial class bookQueryReason : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_AccountBalance_ApplicationUser_UserId", table: "AccountBalance");
migrationBuilder.DropForeignKey(name: "FK_BalanceImpact_AccountBalance_BalanceId", table: "BalanceImpact");
migrationBuilder.DropForeignKey(name: "FK_CommandLine_Estimate_EstimateId", table: "CommandLine");
migrationBuilder.DropForeignKey(name: "FK_BookQuery_ApplicationUser_ClientId", table: "BookQuery");
migrationBuilder.DropForeignKey(name: "FK_BookQuery_PerformerProfile_PerformerId", table: "BookQuery");
migrationBuilder.DropForeignKey(name: "FK_CircleMember_Circle_CircleId", table: "CircleMember");
migrationBuilder.DropForeignKey(name: "FK_CircleMember_ApplicationUser_MemberId", table: "CircleMember");
migrationBuilder.DropForeignKey(name: "FK_PostTag_Blog_PostId", table: "PostTag");
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_Activity_ActivityCode", table: "PerformerProfile");
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_Location_OrganizationAddressId", table: "PerformerProfile");
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_ApplicationUser_PerformerId", table: "PerformerProfile");
migrationBuilder.AddColumn<string>(
name: "Reason",
table: "BookQuery",
nullable: true);
migrationBuilder.AddForeignKey(
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
table: "AspNetRoleClaims",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
table: "AspNetUserRoles",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AccountBalance_ApplicationUser_UserId",
table: "AccountBalance",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_BalanceImpact_AccountBalance_BalanceId",
table: "BalanceImpact",
column: "BalanceId",
principalTable: "AccountBalance",
principalColumn: "UserId",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_CommandLine_Estimate_EstimateId",
table: "CommandLine",
column: "EstimateId",
principalTable: "Estimate",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_BookQuery_ApplicationUser_ClientId",
table: "BookQuery",
column: "ClientId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_BookQuery_PerformerProfile_PerformerId",
table: "BookQuery",
column: "PerformerId",
principalTable: "PerformerProfile",
principalColumn: "PerformerId",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_CircleMember_Circle_CircleId",
table: "CircleMember",
column: "CircleId",
principalTable: "Circle",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_CircleMember_ApplicationUser_MemberId",
table: "CircleMember",
column: "MemberId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_PostTag_Blog_PostId",
table: "PostTag",
column: "PostId",
principalTable: "Blog",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_PerformerProfile_Activity_ActivityCode",
table: "PerformerProfile",
column: "ActivityCode",
principalTable: "Activity",
principalColumn: "Code",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_PerformerProfile_Location_OrganizationAddressId",
table: "PerformerProfile",
column: "OrganizationAddressId",
principalTable: "Location",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_PerformerProfile_ApplicationUser_PerformerId",
table: "PerformerProfile",
column: "PerformerId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
migrationBuilder.DropForeignKey(name: "FK_AccountBalance_ApplicationUser_UserId", table: "AccountBalance");
migrationBuilder.DropForeignKey(name: "FK_BalanceImpact_AccountBalance_BalanceId", table: "BalanceImpact");
migrationBuilder.DropForeignKey(name: "FK_CommandLine_Estimate_EstimateId", table: "CommandLine");
migrationBuilder.DropForeignKey(name: "FK_BookQuery_ApplicationUser_ClientId", table: "BookQuery");
migrationBuilder.DropForeignKey(name: "FK_BookQuery_PerformerProfile_PerformerId", table: "BookQuery");
migrationBuilder.DropForeignKey(name: "FK_CircleMember_Circle_CircleId", table: "CircleMember");
migrationBuilder.DropForeignKey(name: "FK_CircleMember_ApplicationUser_MemberId", table: "CircleMember");
migrationBuilder.DropForeignKey(name: "FK_PostTag_Blog_PostId", table: "PostTag");
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_Activity_ActivityCode", table: "PerformerProfile");
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_Location_OrganizationAddressId", table: "PerformerProfile");
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_ApplicationUser_PerformerId", table: "PerformerProfile");
migrationBuilder.DropColumn(name: "Reason", table: "BookQuery");
migrationBuilder.AddForeignKey(
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
table: "AspNetRoleClaims",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
table: "AspNetUserClaims",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
table: "AspNetUserLogins",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
table: "AspNetUserRoles",
column: "RoleId",
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
table: "AspNetUserRoles",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_AccountBalance_ApplicationUser_UserId",
table: "AccountBalance",
column: "UserId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_BalanceImpact_AccountBalance_BalanceId",
table: "BalanceImpact",
column: "BalanceId",
principalTable: "AccountBalance",
principalColumn: "UserId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_CommandLine_Estimate_EstimateId",
table: "CommandLine",
column: "EstimateId",
principalTable: "Estimate",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_BookQuery_ApplicationUser_ClientId",
table: "BookQuery",
column: "ClientId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_BookQuery_PerformerProfile_PerformerId",
table: "BookQuery",
column: "PerformerId",
principalTable: "PerformerProfile",
principalColumn: "PerformerId",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_CircleMember_Circle_CircleId",
table: "CircleMember",
column: "CircleId",
principalTable: "Circle",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_CircleMember_ApplicationUser_MemberId",
table: "CircleMember",
column: "MemberId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_PostTag_Blog_PostId",
table: "PostTag",
column: "PostId",
principalTable: "Blog",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_PerformerProfile_Activity_ActivityCode",
table: "PerformerProfile",
column: "ActivityCode",
principalTable: "Activity",
principalColumn: "Code",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_PerformerProfile_Location_OrganizationAddressId",
table: "PerformerProfile",
column: "OrganizationAddressId",
principalTable: "Location",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_PerformerProfile_ApplicationUser_PerformerId",
table: "PerformerProfile",
column: "PerformerId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
}
}

@ -448,6 +448,8 @@ namespace Yavsc.Migrations
b.Property<decimal?>("Previsional");
b.Property<string>("Reason");
b.Property<DateTime?>("ValidationDate");
b.HasKey("Id");

@ -25,7 +25,9 @@ namespace Yavsc.Models.Booking
get;
set;
}
public string Reason { get; set; }
public BookQuery()
{
}

@ -12,5 +12,7 @@ namespace Yavsc.Model
public DateTime EventDate { get; set; }
public decimal? Previsional { get; set; }
public string Reason { get; set; }
}
}

@ -197,6 +197,7 @@
<data name="FillInAFutureDate"><value>Please, use a date in the future as starting date.</value></data>
<data name="Forbidden"><value>Restricted area</value></data>
<data name="from"><value>from</value></data>
<data name="GiveAnExplicitReason"><value>Tell more, below, about your query</value></data>
<data name="GoogleDidntGeoLocalized"><value>Google could'nt identify this place</value></data>
<data name="Google calendar"><value>Google calendar</value></data>
<data name="Google error"><value>Google error : {0}</value></data>

@ -218,6 +218,7 @@
<data name="Full name"><value>Nom complet</value></data>
<data name="GCM Notification sending failed"><value>L'envoi du message push a échoué</value></data>
<data name="GCM Notifications sent"><value>Message push envoyé</value></data>
<data name="GiveAnExplicitReason"><value>Dites en plus, ci àprès, à propos de cet évennement</value></data>
<data name="GoogleDidntGeoLocalized"><value>Google n'a pas pu identifier ce lieu</value></data>
<data name="Google calendar"><value>Agenda Google</value></data>
<data name="Google error"><value>Erreur Google : {0}</value></data>
@ -376,4 +377,6 @@
<data name="YourPosts"><value>Vos publications</value></data>
<data name="YourProfile"><value>Votre profile</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>
</root>

@ -30,7 +30,8 @@ namespace Yavsc.Models.Auth
public string Address { get; set; }
}
public class MyUpdate {
public class UserInfo {
public string UserId { get; set; }
public string UserName { get; set; }
public string Avatar { get; set; }

@ -0,0 +1,9 @@
namespace Yavsc.ViewModels.Administration {
public class AdminViewModel {
public RoleInfo [] Roles { get; set; }
public int AdminCount { get; set; }
public bool YouAreAdmin { get; set; }
}
}

@ -0,0 +1,22 @@
using System.Linq;
using Microsoft.AspNet.Identity.EntityFramework;
namespace Yavsc.ViewModels.Administration
{
public class RoleInfo
{
public RoleInfo ()
{
}
public RoleInfo ( IdentityRole role)
{
Name = role.Name;
Id = role.Id;
Users = role.Users.Select(u => u.UserId).ToArray();
}
public string Id { get; set; }
public string Name { get; set; }
public string[] Users { get; set; }
}
}

@ -0,0 +1,15 @@
using Yavsc.Models.Auth;
namespace Yavsc.ViewModels.Administration
{
public class RoleUserCollection
{
public RoleUserCollection()
{
}
public string Id { get; set; }
public string Name { get; set; }
public UserInfo[] Users { get; set; }
}
}

@ -0,0 +1,22 @@
@model AdminViewModel
@{ 
ViewBag.Title = SR["Administration"];
}
<h2>@ViewBag.Title</h2>
<p>
Rôles :
<ul>
@foreach (var role in Model.Roles) {
<li>@Html.ActionLink(role.Name,"Role",new { id=role.Id }) (@role.Users.Length membres)</li>
}
</ul>
</p>
<p>
Nombre d'administrateurs :
@Model.AdminCount
</p>
<p>
Vous êtes administrateur: @(Model.YouAreAdmin?"Oui":"Non")
</p>

@ -0,0 +1,14 @@
@model RoleUserCollection
@{ 
ViewBag.Title = SR["Role"]+" "+Model.Name;
}
<h2>@ViewBag.Title</h2>
<ul>
@foreach (var user in Model.Users) {
<li> <img src="~/Avatars/@(user.UserName).xs.png" alt="avatar"/>
@user.UserName
</li>
}
</ul>

@ -39,9 +39,7 @@
<script src="~/js/to-markdown.js"></script>
<script src="~/js/md-helpers.js"></script>
<script>
$(document).ready(function() {
var editortitre = new Quill('#Titlecnt', {
modules: { toolbar: '#Titletoolbar' },
theme: 'snow'

@ -183,6 +183,17 @@ $(document).ready(function(){
@Html.HiddenFor(model=>model.PerformerId)
</div>
<div class="form-group" has-feedback>
<fieldset>
<legend>
<label for="Reason" class="col-md-2 control-label">
@SR["GiveAnExplicitReason"]
</label>
</legend>
<textarea rows="15" asp-for="Reason" type="text" name="Reason" id="Reason" maxlength="4096"
style="width:100%"></textarea>
<span asp-validation-for="Reason" class="text-danger"></span>
</fieldset>
</form>

@ -2,9 +2,14 @@
<div class="performer @(Model.Active?"active":"inactive")">
@if (Model.Performer != null) {
@if (Model.Performer.Avatar != null) {
<img src="~/Avatars/@Model.Performer.Avatar" alt="avatar">
}
@Model.Performer.UserName
<ul>
<li>@Model.Performer.UserName (rating: @Model.Rate%)</li>
<li> @SR["Rating"]: @Model.Rate % </li>
@if (Model.MinDailyCost != null) {
<li>@SR["MinDailyCost"]: @Model.MinDailyCost&euro;</li>
}

@ -18,6 +18,7 @@
@using Yavsc.ViewModels.Manage;
@using Yavsc.ViewModels.Calendar;
@using Yavsc.ViewModels.Auth;
@using Yavsc.ViewModels.Administration;
@inject IViewLocalizer LocString
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"

Loading…