Пример #1
0
 public async Task<UpdateMobileProfileOutput> UpdateMobileProfile(int userId, UpdateMobileProfileInput input)
 {
     UpdateMobileProfileOutput output = (UpdateMobileProfileOutput)null;
     ApplicationUser user = await this.UserManager.FindByIdAsync(userId);
     if (user != null)
     {
         output = new UpdateMobileProfileOutput()
         {
             Status = 1
         };
         user.Email = input.Email;
         IdentityResult res = await this.UserManager.UpdateAsync(user);
         if (res.Succeeded)
         {
             string[] scopeClaims = new string[6]
             {
     "displayName",
     "profile:cmnd",
     "profile:avartar",
     "profile:cty",
     "profile:diachi",
     "profile:mst"
             };
             IList<Claim> claims = await this.UserManager.GetClaimsAsync(user.Id);
             foreach (Claim claim in Enumerable.Where<Claim>((IEnumerable<Claim>)claims, (Func<Claim, bool>)(m => Enumerable.Contains<string>((IEnumerable<string>)scopeClaims, m.Type))))
             {
                 IdentityResult identityResult = await this.UserManager.RemoveClaimAsync(user.Id, claim);
             }
             if (!string.IsNullOrEmpty(input.DisplayName))
             {
                 IdentityResult identityResult1 = await this.UserManager.AddClaimAsync(user.Id, new Claim("displayName", input.DisplayName));
             }
             if (!string.IsNullOrEmpty(input.Cmnd))
             {
                 IdentityResult identityResult2 = await this.UserManager.AddClaimAsync(user.Id, new Claim("profile:cmnd", input.Cmnd));
             }
             if (!string.IsNullOrEmpty(input.CongTy))
             {
                 IdentityResult identityResult3 = await this.UserManager.AddClaimAsync(user.Id, new Claim("profile:cty", input.CongTy));
             }
             if (!string.IsNullOrEmpty(input.DiaChi))
             {
                 IdentityResult identityResult4 = await this.UserManager.AddClaimAsync(user.Id, new Claim("profile:diachi", input.DiaChi));
             }
             if (!string.IsNullOrEmpty(input.MaSoThue))
             {
                 IdentityResult identityResult5 = await this.UserManager.AddClaimAsync(user.Id, new Claim("profile:mst", input.MaSoThue));
             }
             if (!string.IsNullOrEmpty(input.Avatar))
             {
                 IdentityResult identityResult6 = await this.UserManager.AddClaimAsync(user.Id, new Claim("profile:avartar", input.Avatar));
             }
             output.Status = 0;
         }
     }
     return output;
 }
Пример #2
0
 public async Task<UpdateMobileProfileOutput> UpdateMobileProfile(UpdateMobileProfileInput input)
 {
     UpdateMobileProfileOutput output = await _userBll.UpdateMobileProfile(User.Identity.GetUserId<int>(), input);
     return output;
 }