public int?GetCurrentUserRating(string email) { byte[] currentUserRating = (from review in _reviews.AsParallel() where review.UserId == UserCritic.GetByEmail(email).Id select review.Point).ToArray(); if (currentUserRating.Length == 1) { return(currentUserRating[0]); } return(null); }
public override bool IsValid(object value) { if (value != null) { UserCritic[] users = UserCritic.GetByName(value.ToString()); if (users == null) { return(true); } } return(false); }
public override bool IsValid(object value) { if (value != null) { UserCritic[] users = UserCritic.GetByName(value.ToString()); if (users == null || users[0].Username == ProfileCritic.Instance.CurrentUserCritic.Username) { return(true); } } return(false); }
public UserProfileViewModel(Guid id) { using (App_Data.DataLayerEF.maxcriticEntities context = new App_Data.DataLayerEF.maxcriticEntities()) { App_Data.DataLayerEF.UserCritic[] users = (from u in context.UserCritics.AsParallel() where u.UserId == id select u).ToArray(); if (users.Length == 1) { User = users[0]; } Reviews = Review.GetReviewByUser(UserCritic.GetById(User.UserId))?.Where(rev => rev.CheckedByAdmin == true)?.OrderByDescending(rev => rev.Time)?.ToArray(); PaginationId = Guid.NewGuid(); } }
public void ChangeRole(Guid id, string role) { UserCritic userFromMySchema = UserCritic.GetById(id); ApplicationUserManager userManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>(); ApplicationUser user = userManager.FindByEmail(userFromMySchema.Email); IList <string> roles = userManager.GetRoles(user.Id); foreach (var rol in roles) { userManager.RemoveFromRole(user.Id, rol); } userManager.AddToRole(user.Id, role); UserCritic.Role userRole = (UserCritic.Role)Enum.Parse(typeof(UserCritic.Role), role); userFromMySchema.UserRole = userRole; userFromMySchema.Save(); }