Exemple #1
0
        public UserReturnModel Create(User user)
        {
            if (user == null) throw new ArgumentNullException(nameof(user));

            var model = Mapper.Map<UserReturnModel>(user);
            model.Url = _urlHelper.Link("GetUserById", new {id = user.Id});
            model.Roles = _userManager.GetRolesAsync(user.Id).Result;
            model.Claims = _userManager.GetClaimsAsync(user.Id).Result;
            model.Personae = user.Personae.Select(CreateLite).ToList();
            return model;
        }
        public static IEnumerable<Claim> GetClaims(User user)
        {
            List<Claim> claims = new List<Claim>();

            var daysInGame = user.JoinDate.HasValue
                ? (DateTime.Now.Date - user.JoinDate.Value).TotalDays
                : 0;

            if (daysInGame > 90)
            {
                claims.Add(CreateClaim("Novice", "1"));
            }
            else
            {
                claims.Add(CreateClaim("Novice", "0"));
            }

            return claims;
        }
Exemple #3
0
        private UserReturnModelLite CreateLite(User user)
        {
            if (user == null) throw new ArgumentNullException(nameof(user));

            var model = Mapper.Map<UserReturnModelLite>(user);
            model.Url = _urlHelper.Link("GetUserById", new {id = user.Id});
            return model;
        }