Пример #1
0
        public async Task <UpdateProfileResponse> UpdateProfile(UpdateProfileRequest request)
        {
            var response = new UpdateProfileResponse();
            var user     = await _sessionManager.GetUser();

            var dbRequest = new Repositories.DatabaseRepos.UserRepo.Models.UpdateUserRequest()
            {
                Id            = user.Id,
                Username      = request.Username,
                Email_Address = request.EmailAddress,
                First_Name    = request.FirstName,
                Last_Name     = request.LastName,
                Mobile_Number = request.MobileNumber,
                Updated_By    = user.Id
            };

            using (var uow = _uowFactory.GetUnitOfWork())
            {
                await uow.UserRepo.UpdateUser(dbRequest);

                uow.Commit();
            }

            await _sessionManager.DehydrateSession(); // user has changed

            await _sessionManager.WriteSessionLogEvent(new Models.ManagerModels.Session.CreateSessionLogEventRequest()
            {
                EventKey = SessionEventKeys.UserUpdatedProfile,
            });

            response.Notifications.Add("Profile updated successfully", NotificationTypeEnum.Success);
            return(response);
        }
        public async Task SignIn(Guid sessionGuid, string entityId)
        {
            await _sessionManager.DehydrateSession();

            var claims = new List <Claim>()
            {
                new Claim(ClaimTypes.Name, sessionGuid.ToString())
            };

            var claimsIdentity = new ClaimsIdentity(
                claims, CookieAuthenticationDefaults.AuthenticationScheme);

            await _httpContextAccessor.HttpContext.SignInAsync(
                CookieAuthenticationDefaults.AuthenticationScheme,
                new ClaimsPrincipal(claimsIdentity));
        }