コード例 #1
0
        public UserViewModel(ApplicationUser user)
        {
            this.UserId = user.Id;
            this.UserName = user.UserName;
            this.roles = new List<string>();

            foreach (var role in user.Roles)
            {
                roles.Add(this.EscortServiceData.Roles.Where(r => r.Id == role.RoleId).Select(r => r.Name).ToString());
            }
        }
コード例 #2
0
        public GestGetEscortViewModel(ApplicationUser escort)
        {
            this.UserName = escort.UserName;

            this.Gender = escort.Gender.ToString();
        }
コード例 #3
0
        public async Task<IHttpActionResult> RegisterExternal(RegisterExternalBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var info = await Authentication.GetExternalLoginInfoAsync();
            if (info == null)
            {
                return InternalServerError();
            }

            var user = new ApplicationUser() { UserName = model.Email, Email = model.Email };

            IdentityResult result = await UserManager.CreateAsync(user);
            if (!result.Succeeded)
            {
                return GetErrorResult(result);
            }

            result = await UserManager.AddLoginAsync(user.Id, info.Login);
            if (!result.Succeeded)
            {
                return GetErrorResult(result); 
            }
            return Ok();
        }