public Task <Result> JoinRequest(CreateLinkedUserModel model)
        => Result.TryAsync(async() =>
        {
            var firstUser = (await _repository.FirstOrDefaultAsync <User>(u => u.Id == model.FirstUserId))
                            .Data;
            if (firstUser == null)
            {
                return(Result.Failed(Error.WithCode(ErrorCodes.NotFound)));
            }

            var secondUser = (await _repository.FirstOrDefaultAsync <User>(u => u.Id == generalDataService.User.Id))
                             .Data;
            if (secondUser == null)
            {
                return(Result.Failed(Error.WithCode(ErrorCodes.NotFound)));
            }


            var linkedUser = new LinkedUser
            {
                Id           = Guid.NewGuid(), CreationDate = DateTime.Now, FirstUser = firstUser, SecondUser = secondUser,
                RelationType = model.RelationType,
                LinkStatus   = (byte)LinkStatus.Pending
            };
            _repository.Add(linkedUser);
            await _repository.CommitAsync();
            return(Result.Successful());
        });
        public Task <Result <Guid> > Add(CreateLinkedUserModel model)
        => Result <Guid> .TryAsync(async() =>
        {
            var LinkedUser = new LinkedUser
            {
                Id           = Guid.NewGuid(), FirstUserId = model.FirstUserId ?? generalDataService.User.Id,
                SecondUserId = model.SecondUserId, CreationDate = DateTime.Now,
                LinkStatus   = (byte)LinkStatus.Pending
            };

            _repository.Add(LinkedUser);
            await _repository.CommitAsync();
            return(Result <Guid> .Successful(LinkedUser.Id));
        });
예제 #3
0
        public async Task <Result> SurveyJoinRequest([FromQuery] Guid surveyId, CreateLinkedUserModel model)
        {
            var joinRequest = await _membershipServiceApi.MembershipLinkedUserApiService.JoinRequest(model);

            var userId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "Id").Value);

            var usersurvey = await _userSurveyBiz.GetByUserIdAndSurveyId(userId, surveyId);

            var userDependentSurvey = new UserDependentSurvey
            {
                Id           = Guid.NewGuid(),
                UserId       = model.FirstUserId.Value,
                UserSurveyId = usersurvey.Data.Id
            };

            _repository.Add(userDependentSurvey);
            await _repository.CommitAsync();

            return(Result.Successful());
        }
 public async Task <Result> JoinRequest(CreateLinkedUserModel model)
 => await _linkedUserBiz.JoinRequest(model);
 public async Task <Result <Guid> > Add(CreateLinkedUserModel model)
 => await _linkedUserBiz.Add(model);
예제 #6
0
 public async Task <Result> JoinRequest(CreateLinkedUserModel model)
 => await _membershipServiceApi.MembershipLinkedUserApiService.JoinRequest(model);
예제 #7
0
 public async Task <Result <Guid> > Add(CreateLinkedUserModel model)
 => await _membershipServiceApi.MembershipLinkedUserApiService.Add(model);