예제 #1
0
        public MemberView PatchPersonalInfo(string userName, MemberPersonalInfoView memberPreferencesView)
        {
            if (!EmailChecker.IsValidEmail(memberPreferencesView.Email))
            {
                throw new CoralTimeDangerException("Invalid email");
            }

            CheckRelatedEntities(userName, out var memberByName);
            memberByName          = Uow.MemberRepository.GetQueryByUserName(userName);
            memberByName.FullName = memberPreferencesView.FullName;

            try
            {
                Uow.MemberRepository.Update(memberByName);

                Uow.Save();

                _memberService.ChangeEmailByUserAsync(memberByName, memberPreferencesView.Email).GetAwaiter().GetResult();
                _memberService.UpdateUserClaims(memberByName.Id);

                Uow.MemberRepository.LinkedCacheClear();
                return(memberByName.GetView(Mapper));
            }
            catch (Exception e)
            {
                throw new CoralTimeSafeEntityException("An error occurred while updating member", e);
            }
        }
예제 #2
0
        public MemberView PatchPersonalInfo(MemberPersonalInfoView memberPreferencesView)
        {
            if (!EmailChecker.IsValidEmail(memberPreferencesView.Email))
            {
                throw new CoralTimeDangerException("Invalid email");
            }

            if (_isDemo)
            {
                throw new CoralTimeForbiddenException("Full name can't be changed on demo site");
            }

            CheckRelatedEntities(ImpersonatedUserName, out var memberByName);
            memberByName          = Uow.MemberRepository.GetQueryByUserName(ImpersonatedUserName);
            memberByName.FullName = memberPreferencesView.FullName;

            Uow.MemberRepository.Update(memberByName);
            Uow.Save();

            _memberService.ChangeEmailByUserAsync(memberByName, memberPreferencesView.Email).GetAwaiter().GetResult();
            _memberService.UpdateUserClaims(memberByName.Id);

            Uow.MemberRepository.LinkedCacheClear();

            var urlIcon    = _avatarService.GetUrlIcon(memberByName.Id);
            var memberView = memberByName.GetView(Mapper, urlIcon);

            return(memberView);
        }
예제 #3
0
        public IActionResult Patch(int id, [FromBody] MemberPersonalInfoView memberPersonalInfoView)
        {
            memberPersonalInfoView.Id = id;

            try
            {
                var waitResult = _service.PatchPersonalInfo(memberPersonalInfoView);
                return(Ok(waitResult));
            }
            catch (Exception e)
            {
                _logger.LogWarning($"Patch method with parameters ({id}, {memberPersonalInfoView});\n {e}");
                var errors = ExceptionsChecker.CheckProfileException(e);
                return(BadRequest(errors));
            }
        }
예제 #4
0
        public IActionResult Patch(int id, [FromBody] MemberPersonalInfoView memberPersonalInfoView)
        {
            memberPersonalInfoView.Id = id;

            return(Ok(_service.PatchPersonalInfo(memberPersonalInfoView)));
        }