public override async Task <bool> EnsureValidStateOnPatch(DbContext context, ModelStateDictionary ModelState) { if (!Email.IsEmail()) { ModelState.AddModelError($"{nameof(Account.Email)}", "The email isn't valid"); return(false); } if ((!string.IsNullOrWhiteSpace(AvatarPath) && !AvatarPath.IsUrl())) { ModelState.AddModelError($"{nameof(Account.AvatarPath)}", "The avatar path must be a valid url"); return(false); } if (string.IsNullOrWhiteSpace(Password)) { ModelState.AddModelError($"{nameof(Account.Password)}", "The password must be no null or empty"); return(false); } // if ((await context.Set<Account>().AnyAsync(x => x.Email == Email))) // { // ModelState.AddModelError($"{nameof(Account.Email)}", "Already exists a account with this email"); // return false; // } if (RolesId != null) { foreach (var roleId in RolesId) { if (!(await context.Set <Role>().AnyAsync(x => x.Id == roleId))) { ModelState.AddModelError($"{nameof(Account.Roles)}", $"The role with id: {roleId} don't exists"); return(false); } } } else { ModelState.AddModelError($"{nameof(Account.Roles)}", $"The account must have least one role"); return(false); } return(await base.EnsureValidStateOnPatch(context, ModelState)); }
/// <summary>加载时触发</summary> protected override void OnLoaded() { #if __CORE__ if (StartPage.IsNullOrEmpty()) { StartPage = // 避免出现生成 "/Admin/Admin/Index/Main" 这样的情况 //NewLife.Web.HttpContext.Current?.Request.PathBase.ToString().EnsureEnd("/") + "/Admin/Index/Main"; } #else if (StartPage.IsNullOrEmpty()) { StartPage = System.Web.HttpRuntime.AppDomainAppVirtualPath.EnsureEnd("/") + "Admin/Index/Main"; } #endif var web = Runtime.IsWeb; if (AvatarPath.IsNullOrEmpty()) { AvatarPath = web ? "..\\Avatars" : "Avatars"; } if (DefaultRole.IsNullOrEmpty() || DefaultRole == "3") { DefaultRole = "普通用户"; } // 取版权信息 if (Copyright.IsNullOrEmpty()) { var asm = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly(); if (asm != null) { var att = asm.GetCustomAttribute <AssemblyCopyrightAttribute>(); if (att != null) { Copyright = att.Copyright; } } } base.OnLoaded(); }
public bool Equals(GroupV2 input) { if (input == null) { return(false); } return (( GroupId == input.GroupId || (GroupId.Equals(input.GroupId)) ) && ( Name == input.Name || (Name != null && Name.Equals(input.Name)) ) && ( GroupType == input.GroupType || (GroupType != null && GroupType.Equals(input.GroupType)) ) && ( MembershipIdCreated == input.MembershipIdCreated || (MembershipIdCreated.Equals(input.MembershipIdCreated)) ) && ( CreationDate == input.CreationDate || (CreationDate != null && CreationDate.Equals(input.CreationDate)) ) && ( ModificationDate == input.ModificationDate || (ModificationDate != null && ModificationDate.Equals(input.ModificationDate)) ) && ( About == input.About || (About != null && About.Equals(input.About)) ) && ( Tags == input.Tags || (Tags != null && Tags.SequenceEqual(input.Tags)) ) && ( MemberCount == input.MemberCount || (MemberCount.Equals(input.MemberCount)) ) && ( IsPublic == input.IsPublic || (IsPublic != null && IsPublic.Equals(input.IsPublic)) ) && ( IsPublicTopicAdminOnly == input.IsPublicTopicAdminOnly || (IsPublicTopicAdminOnly != null && IsPublicTopicAdminOnly.Equals(input.IsPublicTopicAdminOnly)) ) && ( Motto == input.Motto || (Motto != null && Motto.Equals(input.Motto)) ) && ( AllowChat == input.AllowChat || (AllowChat != null && AllowChat.Equals(input.AllowChat)) ) && ( IsDefaultPostPublic == input.IsDefaultPostPublic || (IsDefaultPostPublic != null && IsDefaultPostPublic.Equals(input.IsDefaultPostPublic)) ) && ( ChatSecurity == input.ChatSecurity || (ChatSecurity != null && ChatSecurity.Equals(input.ChatSecurity)) ) && ( Locale == input.Locale || (Locale != null && Locale.Equals(input.Locale)) ) && ( AvatarImageIndex == input.AvatarImageIndex || (AvatarImageIndex.Equals(input.AvatarImageIndex)) ) && ( Homepage == input.Homepage || (Homepage != null && Homepage.Equals(input.Homepage)) ) && ( MembershipOption == input.MembershipOption || (MembershipOption != null && MembershipOption.Equals(input.MembershipOption)) ) && ( DefaultPublicity == input.DefaultPublicity || (DefaultPublicity != null && DefaultPublicity.Equals(input.DefaultPublicity)) ) && ( Theme == input.Theme || (Theme != null && Theme.Equals(input.Theme)) ) && ( BannerPath == input.BannerPath || (BannerPath != null && BannerPath.Equals(input.BannerPath)) ) && ( AvatarPath == input.AvatarPath || (AvatarPath != null && AvatarPath.Equals(input.AvatarPath)) ) && ( ConversationId == input.ConversationId || (ConversationId.Equals(input.ConversationId)) ) && ( EnableInvitationMessagingForAdmins == input.EnableInvitationMessagingForAdmins || (EnableInvitationMessagingForAdmins != null && EnableInvitationMessagingForAdmins.Equals(input.EnableInvitationMessagingForAdmins)) ) && ( BanExpireDate == input.BanExpireDate || (BanExpireDate != null && BanExpireDate.Equals(input.BanExpireDate)) ) && ( Features == input.Features || (Features != null && Features.Equals(input.Features)) ) && ( ClanInfo == input.ClanInfo || (ClanInfo != null && ClanInfo.Equals(input.ClanInfo)) )); }
public bool Equals(GroupV2Card input) { if (input == null) { return(false); } return (( GroupId == input.GroupId || (GroupId.Equals(input.GroupId)) ) && ( Name == input.Name || (Name != null && Name.Equals(input.Name)) ) && ( GroupType == input.GroupType || (GroupType != null && GroupType.Equals(input.GroupType)) ) && ( CreationDate == input.CreationDate || (CreationDate != null && CreationDate.Equals(input.CreationDate)) ) && ( About == input.About || (About != null && About.Equals(input.About)) ) && ( Motto == input.Motto || (Motto != null && Motto.Equals(input.Motto)) ) && ( MemberCount == input.MemberCount || (MemberCount.Equals(input.MemberCount)) ) && ( Locale == input.Locale || (Locale != null && Locale.Equals(input.Locale)) ) && ( MembershipOption == input.MembershipOption || (MembershipOption != null && MembershipOption.Equals(input.MembershipOption)) ) && ( Capabilities == input.Capabilities || (Capabilities != null && Capabilities.Equals(input.Capabilities)) ) && ( ClanInfo == input.ClanInfo || (ClanInfo != null && ClanInfo.Equals(input.ClanInfo)) ) && ( AvatarPath == input.AvatarPath || (AvatarPath != null && AvatarPath.Equals(input.AvatarPath)) ) && ( Theme == input.Theme || (Theme != null && Theme.Equals(input.Theme)) )); }