default avatar
@ -26,7 +26,10 @@ namespace Yavsc
|
||||
GCMNotificationUrl = "https://gcm-http.googleapis.com/gcm/send",
|
||||
KeyProtectorPurpose = "OAuth.AspNet.AuthServer",
|
||||
UserFilesPath = "/UserFiles",
|
||||
AvatarsPath = "/Avatars" ;
|
||||
AvatarsPath = "/Avatars",
|
||||
DefaultAvatar = "/images/Users/icon_user.png",
|
||||
AnonAvatar = "/images/Users/icon_anon_user.png";
|
||||
|
||||
public static readonly Scope[] SiteScopes = {
|
||||
new Scope { Id = "profile", Description = "Your profile informations" },
|
||||
new Scope { Id = "book" , Description ="Your booking interface"},
|
||||
|
@ -107,6 +107,7 @@ namespace Yavsc.Helpers
|
||||
{
|
||||
var item = new FileRecievedInfo();
|
||||
item.FileName = user.UserName + ".png";
|
||||
|
||||
var destFileName = Path.Combine(Startup.SiteSetup.UserFiles.Avatars, item.FileName);
|
||||
|
||||
var fi = new FileInfo(destFileName);
|
||||
@ -143,8 +144,9 @@ namespace Yavsc.Helpers
|
||||
}
|
||||
|
||||
}
|
||||
item.DestDir = "/Avatars";
|
||||
user.Avatar = item.FileName;
|
||||
item.DestDir = Startup.AvatarsOptions.RequestPath.ToUriComponent();
|
||||
user.Avatar = $"{item.DestDir}/{item.FileName}";
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
33
Yavsc/Helpers/UserHelpers.cs
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.Helpers
|
||||
{
|
||||
public static class UserHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// The avatar ...
|
||||
/// </summary>
|
||||
/// <param name="dbContext"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="imgFmt"></param>
|
||||
/// <returns></returns>
|
||||
// FIXME support imgFmt
|
||||
public static string AvatarUri(this ApplicationDbContext dbContext, string userId, string imgFmt )
|
||||
{
|
||||
var user = dbContext.Users.FirstOrDefault(u => u.Id == userId);
|
||||
if (user==null) return Constants.AnonAvatar;
|
||||
if (user.Avatar.StartsWith("/"))
|
||||
{
|
||||
// use fmt
|
||||
FileInfo fi = new FileInfo(user.Avatar);
|
||||
var ext = fi.Extension;
|
||||
var avatar = user.Avatar.Substring(0, user.Avatar.Length - ext.Length );
|
||||
return $"{avatar}{imgFmt}{ext}";
|
||||
}
|
||||
return user.Avatar;
|
||||
}
|
||||
}
|
||||
}
|
1112
Yavsc/Migrations/20170201162847_defaultAvatar.Designer.cs
generated
Normal file
427
Yavsc/Migrations/20170201162847_defaultAvatar.cs
Normal file
@ -0,0 +1,427 @@
|
||||
|
||||
using Microsoft.Data.Entity.Migrations;
|
||||
|
||||
namespace Yavsc.Migrations
|
||||
{
|
||||
public partial class defaultAvatar : 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_BlackListed_ApplicationUser_OwnerId", table: "BlackListed");
|
||||
migrationBuilder.DropForeignKey(name: "FK_CircleAuthorizationToBlogPost_Blog_BlogPostId", table: "CircleAuthorizationToBlogPost");
|
||||
migrationBuilder.DropForeignKey(name: "FK_CircleAuthorizationToBlogPost_Circle_CircleId", table: "CircleAuthorizationToBlogPost");
|
||||
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_Estimate_ApplicationUser_ClientId", table: "Estimate");
|
||||
migrationBuilder.DropForeignKey(name: "FK_Estimate_PerformerProfile_OwnerId", table: "Estimate");
|
||||
migrationBuilder.DropForeignKey(name: "FK_BookQuery_Activity_ActivityCode", table: "BookQuery");
|
||||
migrationBuilder.DropForeignKey(name: "FK_BookQuery_ApplicationUser_ClientId", table: "BookQuery");
|
||||
migrationBuilder.DropForeignKey(name: "FK_BookQuery_PerformerProfile_PerformerId", table: "BookQuery");
|
||||
migrationBuilder.DropForeignKey(name: "FK_Instrumentation_Instrument_InstrumentId", table: "Instrumentation");
|
||||
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_CommandForm_Activity_ActivityCode", table: "CommandForm");
|
||||
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_Location_OrganizationAddressId", table: "PerformerProfile");
|
||||
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_ApplicationUser_PerformerId", table: "PerformerProfile");
|
||||
migrationBuilder.DropForeignKey(name: "FK_UserActivity_Activity_DoesCode", table: "UserActivity");
|
||||
migrationBuilder.DropForeignKey(name: "FK_UserActivity_PerformerProfile_UserId", table: "UserActivity");
|
||||
|
||||
migrationBuilder.Sql("UPDATE \"AspNetUsers\" SET \"Avatar\"='/images/Users/icon_user.png' WHERE \"Avatar\" IS NULL");
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Avatar",
|
||||
table: "AspNetUsers",
|
||||
nullable: false,
|
||||
defaultValue: "/images/Users/icon_user.png");
|
||||
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_BlackListed_ApplicationUser_OwnerId",
|
||||
table: "BlackListed",
|
||||
column: "OwnerId",
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_CircleAuthorizationToBlogPost_Blog_BlogPostId",
|
||||
table: "CircleAuthorizationToBlogPost",
|
||||
column: "BlogPostId",
|
||||
principalTable: "Blog",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_CircleAuthorizationToBlogPost_Circle_CircleId",
|
||||
table: "CircleAuthorizationToBlogPost",
|
||||
column: "CircleId",
|
||||
principalTable: "Circle",
|
||||
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_Estimate_ApplicationUser_ClientId",
|
||||
table: "Estimate",
|
||||
column: "ClientId",
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Estimate_PerformerProfile_OwnerId",
|
||||
table: "Estimate",
|
||||
column: "OwnerId",
|
||||
principalTable: "PerformerProfile",
|
||||
principalColumn: "PerformerId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_BookQuery_Activity_ActivityCode",
|
||||
table: "BookQuery",
|
||||
column: "ActivityCode",
|
||||
principalTable: "Activity",
|
||||
principalColumn: "Code",
|
||||
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_Instrumentation_Instrument_InstrumentId",
|
||||
table: "Instrumentation",
|
||||
column: "InstrumentId",
|
||||
principalTable: "Instrument",
|
||||
principalColumn: "Id",
|
||||
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_CommandForm_Activity_ActivityCode",
|
||||
table: "CommandForm",
|
||||
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);
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_UserActivity_Activity_DoesCode",
|
||||
table: "UserActivity",
|
||||
column: "DoesCode",
|
||||
principalTable: "Activity",
|
||||
principalColumn: "Code",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_UserActivity_PerformerProfile_UserId",
|
||||
table: "UserActivity",
|
||||
column: "UserId",
|
||||
principalTable: "PerformerProfile",
|
||||
principalColumn: "PerformerId",
|
||||
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_BlackListed_ApplicationUser_OwnerId", table: "BlackListed");
|
||||
migrationBuilder.DropForeignKey(name: "FK_CircleAuthorizationToBlogPost_Blog_BlogPostId", table: "CircleAuthorizationToBlogPost");
|
||||
migrationBuilder.DropForeignKey(name: "FK_CircleAuthorizationToBlogPost_Circle_CircleId", table: "CircleAuthorizationToBlogPost");
|
||||
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_Estimate_ApplicationUser_ClientId", table: "Estimate");
|
||||
migrationBuilder.DropForeignKey(name: "FK_Estimate_PerformerProfile_OwnerId", table: "Estimate");
|
||||
migrationBuilder.DropForeignKey(name: "FK_BookQuery_Activity_ActivityCode", table: "BookQuery");
|
||||
migrationBuilder.DropForeignKey(name: "FK_BookQuery_ApplicationUser_ClientId", table: "BookQuery");
|
||||
migrationBuilder.DropForeignKey(name: "FK_BookQuery_PerformerProfile_PerformerId", table: "BookQuery");
|
||||
migrationBuilder.DropForeignKey(name: "FK_Instrumentation_Instrument_InstrumentId", table: "Instrumentation");
|
||||
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_CommandForm_Activity_ActivityCode", table: "CommandForm");
|
||||
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_Location_OrganizationAddressId", table: "PerformerProfile");
|
||||
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_ApplicationUser_PerformerId", table: "PerformerProfile");
|
||||
migrationBuilder.DropForeignKey(name: "FK_UserActivity_Activity_DoesCode", table: "UserActivity");
|
||||
migrationBuilder.DropForeignKey(name: "FK_UserActivity_PerformerProfile_UserId", table: "UserActivity");
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Avatar",
|
||||
table: "AspNetUsers",
|
||||
nullable: true);
|
||||
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_BlackListed_ApplicationUser_OwnerId",
|
||||
table: "BlackListed",
|
||||
column: "OwnerId",
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_CircleAuthorizationToBlogPost_Blog_BlogPostId",
|
||||
table: "CircleAuthorizationToBlogPost",
|
||||
column: "BlogPostId",
|
||||
principalTable: "Blog",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_CircleAuthorizationToBlogPost_Circle_CircleId",
|
||||
table: "CircleAuthorizationToBlogPost",
|
||||
column: "CircleId",
|
||||
principalTable: "Circle",
|
||||
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_Estimate_ApplicationUser_ClientId",
|
||||
table: "Estimate",
|
||||
column: "ClientId",
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Estimate_PerformerProfile_OwnerId",
|
||||
table: "Estimate",
|
||||
column: "OwnerId",
|
||||
principalTable: "PerformerProfile",
|
||||
principalColumn: "PerformerId",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_BookQuery_Activity_ActivityCode",
|
||||
table: "BookQuery",
|
||||
column: "ActivityCode",
|
||||
principalTable: "Activity",
|
||||
principalColumn: "Code",
|
||||
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_Instrumentation_Instrument_InstrumentId",
|
||||
table: "Instrumentation",
|
||||
column: "InstrumentId",
|
||||
principalTable: "Instrument",
|
||||
principalColumn: "Id",
|
||||
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_CommandForm_Activity_ActivityCode",
|
||||
table: "CommandForm",
|
||||
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);
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_UserActivity_Activity_DoesCode",
|
||||
table: "UserActivity",
|
||||
column: "DoesCode",
|
||||
principalTable: "Activity",
|
||||
principalColumn: "Code",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_UserActivity_PerformerProfile_UserId",
|
||||
table: "UserActivity",
|
||||
column: "UserId",
|
||||
principalTable: "PerformerProfile",
|
||||
principalColumn: "PerformerId",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Data.Entity.Infrastructure;
|
||||
using Microsoft.Data.Entity.Metadata;
|
||||
using Microsoft.Data.Entity.Migrations;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.Migrations
|
||||
@ -152,7 +154,10 @@ namespace Yavsc.Migrations
|
||||
b.Property<int>("AccessFailedCount");
|
||||
|
||||
b.Property<string>("Avatar")
|
||||
.HasAnnotation("MaxLength", 512);
|
||||
.IsRequired()
|
||||
.HasAnnotation("MaxLength", 512)
|
||||
.HasAnnotation("Relational:DefaultValue", "/images/Users/icon_user.png")
|
||||
.HasAnnotation("Relational:DefaultValueType", "System.String");
|
||||
|
||||
b.Property<long?>("BankInfoId");
|
||||
|
||||
|
@ -37,10 +37,12 @@ namespace Yavsc.Models
|
||||
builder.Entity<GoogleCloudMobileDeclaration>().Property(x=>x.DeclarationDate).HasDefaultValueSql("LOCALTIMESTAMP");
|
||||
builder.Entity<PostTag>().HasKey(x=>new { x.PostId, x.TagId});
|
||||
builder.Entity<ApplicationUser>().HasMany<Connection>( c=>c.Connections );
|
||||
builder.Entity<ApplicationUser>().Property(u=>u.Avatar).HasDefaultValue(Constants.DefaultAvatar);
|
||||
builder.Entity<UserActivity>().HasKey(u=> new { u.DoesCode, u.UserId});
|
||||
builder.Entity<Instrumentation>().HasKey(u=> new { u.InstrumentId, u.UserId});
|
||||
builder.Entity<CircleAuthorizationToBlogPost>().HasKey(a=> new { a.CircleId, a.BlogPostId});
|
||||
builder.Entity<CircleMember>().HasKey(c=> new { MemberId = c.MemberId, CircleId = c.CircleId });
|
||||
|
||||
foreach (var et in builder.Model.GetEntityTypes()) {
|
||||
if (et.ClrType.GetInterface("IBaseTrackedEntity")!=null)
|
||||
et.FindProperty("DateCreated").IsReadOnlyAfterSave = true;
|
||||
|
@ -22,7 +22,7 @@ namespace Yavsc.Models
|
||||
/// <see>Startup.UserFilesOptions</see>
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[MaxLength(512)]
|
||||
[MaxLength(512),Required]
|
||||
public string Avatar { get; set; }
|
||||
|
||||
[MaxLength(512)]
|
||||
|
22
Yavsc/ViewComponents/AvatarViewComponent.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.ViewComponents
|
||||
{
|
||||
public class AvatarViewComponent : ViewComponent
|
||||
{
|
||||
ApplicationDbContext dbContext;
|
||||
public AvatarViewComponent(ApplicationDbContext dbContext)
|
||||
{
|
||||
this.dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<IViewComponentResult> InvokeAsync ( string userId, string imgFmt )
|
||||
{
|
||||
return View ( "Default", dbContext.AvatarUri(userId, imgFmt));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -30,10 +30,4 @@ namespace Yavsc.Models.Auth
|
||||
public string Address { get; set; }
|
||||
}
|
||||
|
||||
public class UserInfo {
|
||||
public string UserId { get; set; }
|
||||
|
||||
public string UserName { get; set; }
|
||||
public string Avatar { get; set; }
|
||||
}
|
||||
}
|
9
Yavsc/ViewModels/Account/UserInfo.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Yavsc.Models.Auth
|
||||
{
|
||||
public class UserInfo {
|
||||
public string UserId { get; set; }
|
||||
|
||||
public string UserName { get; set; }
|
||||
public string Avatar { get; set; }
|
||||
}
|
||||
}
|
@ -48,10 +48,10 @@
|
||||
|
||||
<dt>@SR["Avatar"]:</dt>
|
||||
<dd>
|
||||
<img src="~/Avatars/@(User.Identity.Name).png">
|
||||
@Model.Avatar
|
||||
|
||||
@await Component.InvokeAsync("Avatar", User.GetUserId(), ".s")
|
||||
[<a asp-controller="Manage" asp-action="SetAvatar"
|
||||
>@SR[@Model.Avatar==null?"Set":"Modify"]</a>]
|
||||
>@SR["Modify"]</a>]
|
||||
</dd>
|
||||
|
||||
<dt>@SR["Professional settings"]:</dt>
|
||||
|
2
Yavsc/Views/Shared/Components/Avatar/Default.cshtml
Normal file
@ -0,0 +1,2 @@
|
||||
@model string
|
||||
<img src="@Model" alt="" />
|
@ -6,7 +6,7 @@
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a asp-controller="Manage" class="navbar-link" asp-action="Index" title="Manage">
|
||||
<img src="~/Avatars/@(User.Identity.Name).xs.png" />
|
||||
@await Component.InvokeAsync("Avatar", User.GetUserId(), ".xs")
|
||||
@SR["Hello"] @User.GetUserName()!</a>
|
||||
</li>
|
||||
<li>
|
||||
|
BIN
Yavsc/wwwroot/images/Chat/chat_icon_s.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
Yavsc/wwwroot/images/Chat/connected.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
Yavsc/wwwroot/images/Chat/connecting.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
Yavsc/wwwroot/images/Chat/disconnected.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
Yavsc/wwwroot/images/Chat/reconnecting.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
Yavsc/wwwroot/images/Chat/talk.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
Yavsc/wwwroot/images/Notifications/exclam.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
Yavsc/wwwroot/images/Notifications/exclam_inv.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
Yavsc/wwwroot/images/Users/icon_add_user.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
Yavsc/wwwroot/images/Users/icon_anon_user.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
Yavsc/wwwroot/images/Users/icon_anon_user.xs.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
Yavsc/wwwroot/images/Users/icon_block_user.png
Normal file
After Width: | Height: | Size: 7.0 KiB |
BIN
Yavsc/wwwroot/images/Users/icon_remove_user.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
Yavsc/wwwroot/images/Users/icon_user.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
Yavsc/wwwroot/images/Users/icon_user.s.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
Yavsc/wwwroot/images/Users/icon_user.xs.png
Normal file
After Width: | Height: | Size: 936 B |
BIN
Yavsc/wwwroot/images/Users/icon_user_settings.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
BIN
Yavsc/wwwroot/images/chat_icon.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
Yavsc/wwwroot/images/chat_icon_l.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
Yavsc/wwwroot/images/chat_icon_m.png
Normal file
After Width: | Height: | Size: 3.8 KiB |