本文整理汇总了C#中MembershipUser类的典型用法代码示例。如果您正苦于以下问题:C# MembershipUser类的具体用法?C# MembershipUser怎么用?C# MembershipUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MembershipUser类属于命名空间,在下文中一共展示了MembershipUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetByUser
/// <summary>
/// Return notifications for a specified user
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
public IList<CategoryNotification> GetByUser(MembershipUser user)
{
var cacheKey = string.Concat(CacheKeys.CategoryNotification.StartsWith, "GetByUser-", user.Id);
return _cacheService.CachePerRequest(cacheKey, () => _context.CategoryNotification
.Where(x => x.User.Id == user.Id)
.ToList());
}
示例2: SnitzMembershipUser
public SnitzMembershipUser(MembershipUser mu, int posts,string country)
{
this.mu = mu;
Posts = posts;
Title = mu.Comment;
Country = country;
}
示例3: btnUpdate_Click
private void btnUpdate_Click(object sender, RoutedEventArgs e)
{
try
{
UserPresenter userPresenter = (UserPresenter)this.DataContext;
MembershipUser membershipUser = new MembershipUser();
DeepClone.CopyTo((MembershipUser)(userPresenter.View.dataGridUsers.SelectedItem), membershipUser);
UserEditPresenter userEditPresenter = new UserEditPresenter(new UserEditView(), membershipUser);
userEditPresenter.View.Label_AddOrEditUser.Content = "Edytowanie użytkownika";
if (membershipUser.is_active) { userEditPresenter.View.ComboBox_active.SelectedValue = "TAK"; }
else { userEditPresenter.View.ComboBox_active.SelectedValue = "NIE"; }
if (userEditPresenter.View.ShowDialog() == true)
{
membershipUser.creation_date = DateTime.Now;
userPresenter.SaveUser(membershipUser, true);
MembershipUser temp = (MembershipUser)userPresenter.View.dataGridUsers.SelectedItem;
ChangeCurrentRow(userPresenter, userEditPresenter, temp);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例4: Delete
public void Delete(MembershipUser user, PointsFor type, Guid referenceId)
{
var mp = _context.MembershipUserPoints.Include(x => x.User).Where(x => x.User.Id == user.Id && x.PointsFor == type && x.PointsForId == referenceId);
var mpoints = new List<MembershipUserPoints>();
mpoints.AddRange(mp);
Delete(mpoints);
}
示例5: sendMail
private void sendMail(MembershipUser user)
{
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("[email protected]");
mailMessage.Subject = "Welcome To Tom's List";
mailMessage.To.Add(new MailAddress(user.Email));
Guid userId = (Guid)user.ProviderUserKey;
string body = "";
using (StreamReader reader = new StreamReader(Server.MapPath("~/Templates/NewAccountTemplate.html")))
{
body = reader.ReadToEnd();
}
body = body.Replace("<%UserName%>", user.UserName);
string baseUrl = Request.Url.GetLeftPart(UriPartial.Authority) + (Request.ApplicationPath.Equals("/") ? "" : Request.ApplicationPath);
string verifyUrl = "/Views/AccountVerify.aspx?ID=" + userId.ToString();
body = body.Replace("<%VerifyUrl%>", baseUrl + verifyUrl);
mailMessage.Body = body;
mailMessage.IsBodyHtml = true;
new SmtpClient().Send(mailMessage);
}
示例6: MembershipUserIdentity
public MembershipUserIdentity(MembershipUser user)
{
_user = user;
if (Roles.Enabled)
{
_roles = Roles.GetRolesForUser(user.UserName);
}
}
示例7: AddNewPost
/// <summary>
/// Add a new post
/// </summary>
/// <param name="postContent"> </param>
/// <param name="topic"> </param>
/// <param name="user"></param>
/// <param name="permissions"> </param>
/// <returns>True if post added</returns>
public Post AddNewPost(string postContent, Topic topic, MembershipUser user, out PermissionSet permissions)
{
// Get the permissions for the category that this topic is in
permissions = _roleService.GetPermissions(topic.Category, UsersRole(user));
// Check this users role has permission to create a post
if (permissions[SiteConstants.Instance.PermissionDenyAccess].IsTicked || permissions[SiteConstants.Instance.PermissionReadOnly].IsTicked)
{
// Throw exception so Ajax caller picks it up
throw new ApplicationException(_localizationService.GetResourceString("Errors.NoPermission"));
}
// Has permission so create the post
var newPost = new Post
{
PostContent = postContent,
User = user,
Topic = topic,
IpAddress = StringUtils.GetUsersIpAddress(),
DateCreated = DateTime.UtcNow,
DateEdited = DateTime.UtcNow
};
// Sort the search field out
var category = topic.Category;
if (category.ModeratePosts == true)
{
newPost.Pending = true;
}
var e = new PostMadeEventArgs { Post = newPost };
EventManager.Instance.FireBeforePostMade(this, e);
if (!e.Cancel)
{
// create the post
Add(newPost);
// Update the users points score and post count for posting
_membershipUserPointsService.Add(new MembershipUserPoints
{
Points = _settingsService.GetSettings().PointsAddedPerPost,
User = user,
PointsFor = PointsFor.Post,
PointsForId = newPost.Id
});
// add the last post to the topic
topic.LastPost = newPost;
EventManager.Instance.FireAfterPostMade(this, new PostMadeEventArgs { Post = newPost });
return newPost;
}
return newPost;
}
示例8: GenerateMappedRecord
public static Activity GenerateMappedRecord(MembershipUser user)
{
return new Activity
{
Data = KeyUserId + Equality + user.Id,
Timestamp = user.CreateDate,
Type = ActivityType.MemberJoined.ToString()
};
}
示例9: GenerateMappedRecord
public static Activity GenerateMappedRecord(MembershipUser user, DateTime modified)
{
return new Activity
{
Data = KeyUserId + Equality + user.Id,
Timestamp = modified,
Type = ActivityType.ProfileUpdated.ToString()
};
}
示例10: GetUserStatus
protected string GetUserStatus(MembershipUser user)
{
if (user.IsApproved == false)
return "NOT APPROVED";
else if (user.IsLockedOut)
return "LOCKED";
else
return "Active";
}
示例11: GenerateMappedRecord
public static Activity GenerateMappedRecord(Badge badge, MembershipUser user, DateTime timestamp)
{
return new Activity
{
// badge=badgeId,user=userId
Data = KeyBadgeId + Equality + badge.Id + Separator + KeyUserId + Equality + user.Id,
Timestamp = timestamp,
Type = ActivityType.BadgeAwarded.ToString()
};
}
示例12: GetByUserAndTag
public IList<TagNotification> GetByUserAndTag(MembershipUser user, TopicTag tag, bool addTracking = false)
{
var notifications = _context.TagNotification
.Where(x => x.User.Id == user.Id && x.Tag.Id == tag.Id);
if (addTracking)
{
return notifications.ToList();
}
return notifications.AsNoTracking().ToList();
}
示例13: GetByUserAndCategory
/// <summary>
/// Return notifications for a specified user and category
/// </summary>
/// <param name="user"></param>
/// <param name="category"></param>
/// <param name="addTracking"></param>
/// <returns></returns>
public IList<CategoryNotification> GetByUserAndCategory(MembershipUser user, Category category, bool addTracking = false)
{
var cacheKey = string.Concat(CacheKeys.CategoryNotification.StartsWith, "GetByUserAndCategory-", user.Id, "-", category.Id, "-", addTracking);
return _cacheService.CachePerRequest(cacheKey, () =>
{
var notifications = _context.CategoryNotification.Where(x => x.Category.Id == category.Id && x.User.Id == user.Id);
if (addTracking)
{
return notifications.ToList();
}
return notifications.AsNoTracking().ToList();
});
}
示例14: ResetPassword_OnClick
public void ResetPassword_OnClick(object sender, EventArgs args)
{
string newPassword;
u = Membership.GetUser(UsernameTextBox.Text, false);
if (u == null)
{
Msg.Text = "Username " + Server.HtmlEncode(UsernameTextBox.Text) + " not found. Please check the value and re-enter.";
return;
}
try
{
newPassword = u.ResetPassword(AnswerTextBox.Text);
}
catch (MembershipPasswordException e)
{
Msg.Text = "Invalid password answer. Please re-enter and try again.";
return;
}
catch (Exception e)
{
Msg.Text = e.Message;
return;
}
if (newPassword != null)
{
Msg.Text = "Password reset. Your new password is: " + Server.HtmlEncode(newPassword);
}
else
{
Msg.Text = "Password reset failed. Please re-enter your values and try again.";
}
}
示例15: FuddleUser
public FuddleUser(string username)
{
SqlConnection conn = new SqlConnection(connString);
this.user = Membership.GetUser(username);
this.id = (Guid)user.ProviderUserKey;
this.username = username;
}