Exemple #1
0
        public async Task SetUserprofileRelationship(HttpClient client)
        {
            // Set User profile
            var reqPayload = new UserProfileRegAboutYourRelationshipRequestInfo
            {
                BeenToCounselorOrTherapist = BeenToCounselorOrTherapistType.NoNever,
                HasMoreThanOneMarriage     = false,
                IsMarried        = true,
                LastWeddingDate  = DateTime.Now.AddYears(-20),
                NrOfChildren     = 1,
                NrOfStepChildren = 0
            };

            var postResponse = await client.PutAsync(ApiEndpoints.userprofiles_me_registration_aboutyourrelationship, BaseWebApiTest.GetJsonContent(reqPayload));

            postResponse.EnsureSuccessStatusCode();
        }
Exemple #2
0
        public async Task <IActionResult> SetAboutYourRelationship([FromBody] UserProfileRegAboutYourRelationshipRequestInfo u)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(this.ApiErrorMessage400BadRequest(this.ModelState));
                }

                var jwtPayloadInfo = this.GetJwtPayloadInfo();

                var existingUserProfileId = await _bl.GetCachedUserId_byExternalReferenceIdAsync(jwtPayloadInfo.ExtReferenceId);

                if (existingUserProfileId == null)
                {
                    return(this.ApiErrorMessage400BadRequestUserIdInTokenNotFound(jwtPayloadInfo.ExtReferenceId));
                }

                var bl_relationship = new BL_Relationship
                {
                    BeenToCounseler      = null, //Set in Switch statement below
                    CurrentWeddingDate   = u.LastWeddingDate,
                    RegisteredPartner_Id = null,
                    MarriageStatus       = null, //Set in Switch statement below
                    RelationshipStatus   = null, //Set in Switch statement below
                    NrOfChildren         = u.NrOfChildren,
                    Id = null,
                    NrOfStepChildren = u.NrOfStepChildren,
                };

                switch (u.BeenToCounselorOrTherapist)
                {
                case BeenToCounselorOrTherapistType.NoNever:
                    bl_relationship.BeenToCounseler = BL_Relationship.CounselerStatusEnum.NoNever;
                    break;

                case BeenToCounselorOrTherapistType.Unknown:
                    bl_relationship.BeenToCounseler = BL_Relationship.CounselerStatusEnum.Unknown;
                    break;

                case BeenToCounselorOrTherapistType.YesCurrently:
                    bl_relationship.BeenToCounseler = BL_Relationship.CounselerStatusEnum.YesCurrently;
                    break;

                case BeenToCounselorOrTherapistType.YesInThePast:
                    bl_relationship.BeenToCounseler = BL_Relationship.CounselerStatusEnum.YesInThePast;
                    break;

                default:
                    bl_relationship.BeenToCounseler = null;
                    break;
                }

                switch (u.HasMoreThanOneMarriage)
                {
                case null:
                    bl_relationship.MarriageStatus = null;
                    break;

                case true:
                    bl_relationship.MarriageStatus = BL_Relationship.MarriageStatusEnum.MoreThanOneMarriage;
                    break;

                case false:
                    bl_relationship.MarriageStatus = BL_Relationship.MarriageStatusEnum.FirstMarriage;
                    break;
                }
                switch (u.IsMarried)
                {
                case null:
                    bl_relationship.RelationshipStatus = null;
                    break;

                case true:
                    bl_relationship.RelationshipStatus = BL_Relationship.RelationshipStatusEnum.Married;
                    break;

                case false:
                    bl_relationship.RelationshipStatus = BL_Relationship.RelationshipStatusEnum.NotMarried;
                    break;
                }


                await _bl.SetRelationshipAsync(bl_relationship, existingUserProfileId);

                //var bl_usrProReg = new BL_UserProfileRegistration
                //{
                //    HasMoreThanOneMarriage = u.HasMoreThanOneMarriage,
                //    IsMarried = u.IsMarried,
                //    LastWeddingDate = u.LastWeddingDate,
                //    NrOfChildren = u.NrOfChildren,
                //    NrOfStepChildren = u.NrOfStepChildren,

                //    UserProfile_Id = existingUserProfileId,
                //};
                //await _dl.SetUserProfileRegistrationAsync(bl_usrProReg);
                return(this.ApiPutMessage204NotContent());
            }
            catch (Exception exc)
            {
                return(this.ApiErrorMessage400BadRequest(exc));
            }
        }