Exemplo n.º 1
0
        public async Task <JsonResult> ChangeNickName([FromServices] INickNameProvider nicknameProvider, string name)
        {
            bool success;

            name = Regex.Replace(name, @"\s+", string.Empty);
            var ret = CheckNickName(name);

            if (ret.Value != null)
            {
                return(ret);
            }
            UserProfile user = _db.Users.SingleOrDefault(u => u.UserName == User.Identity.Name);

            var result = await _expUtil.trySpendPointAsync(User.Identity.Name, 200);

            int points = result.Item2;

            if (result.Item1 == false)
            {
                success = false;
            }
            else
            {
                user.NickName = name;
                await _db.SaveChangesAsync();

                nicknameProvider.UpdateNickNameCache(user);
                success = true;
            }
            return(Json(new { success = success, points = points }));
        }
Exemplo n.º 2
0
 public TreasureHuntController(
     UsersContext udb, IMemoryCache cache, INickNameProvider nickNameProvider, ExpUtil expUtil)
 {
     _udb              = udb;
     _cache            = cache;
     _nickNameProvider = nickNameProvider;
     _expUtil          = expUtil;
 }
Exemplo n.º 3
0
 public ContextlessBlogUtil(
     BlogContext db,
     UsersContext udb,
     IMemoryCache cache,
     IVisitCounter visitCounter,
     INickNameProvider nicknameProvider) : base(db, udb, cache)
 {
     _nicknameProvider = nicknameProvider;
     _visitCounter     = visitCounter;
 }
Exemplo n.º 4
0
 public PunchInController(
     UsersContext udb,
     ExpUtil expUtil,
     IOptions <AppSettingsModel> appSettings,
     IMemoryCache cache,
     IHttpContextAccessor contextAccessor,
     INickNameProvider nickNameProvider)
 {
     _udb = udb;
     _nickNameProvider = nickNameProvider;
     _expUtil          = expUtil;
     _appSettings      = appSettings.Value;
     _cache            = cache;
     _contextAccessor  = contextAccessor;
 }
Exemplo n.º 5
0
 public AccountController(
     UserManager <UserProfile> userManager,
     SignInManager <UserProfile> signInManager,
     RoleManager <AspNetCore.Identity.EntityFramework6.IdentityRole> roleManager,
     INickNameProvider nickNameProvider,
     IAntiforgery antiforgery,
     UrlEncoder urlEncoder)
 {
     _userManager      = userManager;
     _signInManager    = signInManager;
     _roleManager      = roleManager;
     _antiforgery      = antiforgery;
     _nickNameProvider = nickNameProvider;
     _urlEncoder       = urlEncoder;
 }
Exemplo n.º 6
0
        public async Task <JsonResult> ChangeTitle([FromServices] INickNameProvider nicknameProvider, UserQuest.UserProfession?title)
        {
            if (!title.HasValue)
            {
                return(Json(new { success = false }));
            }
            var user = await GetCurrentUserAsync();

            if (user.quest == null || !user.quest.HasTitle(title.Value))
            {
                return(Json(new { success = false }));
            }
            user.quest.Title = title.Value;
            var result = await _userManager.UpdateAsync(user);

            nicknameProvider.UpdateNickNameCache(user);
            return(Json(new { success = result.Succeeded, current = user.quest.Title.ToString() }));
        }
Exemplo n.º 7
0
 public BlogController(
     IOptions <AppSettingsModel> appSettings,
     BlogContext db,
     UsersContext udb,
     CategoryUtil catUtil,
     BlogUtil blogUtil,
     RatingUtil ratingUtil,
     DbBlogSearchProvider dbBlogSearchProvider,
     INickNameProvider nickNameProvider)
 {
     db_                   = db;
     udb_                  = udb;
     blogUtil_             = blogUtil;
     ratingUtil_           = ratingUtil;
     appSettings_          = appSettings.Value;
     dbBlogSearchProvider_ = dbBlogSearchProvider;
     nickNameProvider_     = nickNameProvider;
     categoryUtil_         = catUtil;
 }
Exemplo n.º 8
0
 public BlogUtil(
     BlogContext db,
     UsersContext udb,
     IMemoryCache cache,
     IHttpContextAccessor contextAccessor,
     IUrlHelper urlHelper,
     MessageUtil msgUtil,
     AdminUtil adminUtil,
     UploadUtil uploadUtil,
     ExpUtil expUtil,
     IVisitCounter visitCounter,
     INickNameProvider nicknameProvider) : base(db, udb, cache, visitCounter, nicknameProvider)
 {
     _msgUtil         = msgUtil;
     _adminUtil       = adminUtil;
     _contextAccessor = contextAccessor;
     _urlHelper       = urlHelper;
     _uploadUtil      = uploadUtil;
     _expUtil         = expUtil;
     _visitCounter    = visitCounter;
 }