public void UpdateUserEmail_InValid()
        {
            string Test_Case   = string.Empty;
            string description = string.Empty;

            UpdateUserEmailRequest[] request = null;
            int i = 0;

            for (i = 0; i < 2; i++)
            {
                if (i == 0)
                {
                    Test_Case   = "UpdateUserEmail_InValidBlankData";
                    description = "To verify response object for the UpdateUserEmail method with blank field.";
                    request     = new UpdateUserEmailRequest[] {
                        new UpdateUserEmailRequest()
                        {
                        }
                    };
                }

                else if (i == 1)
                {
                    Test_Case   = "UpdateUserEmail_InValidJunkData";
                    description = "To verify response object for the UpdateUserEmail method with junk field.";
                    request     = new UpdateUserEmailRequest[] {
                        new UpdateUserEmailRequest()
                        {
                            ContactCrmId = junkContactcrmids,
                            Email        = junkContactcrmids
                        }
                    };
                }
                else
                {
                    _writer.WriteLog(serviceName, Test_Case, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), description, SBWSCommon.StatusLevelOptions.FAIL.ToString(), "Proper Response not return on Test Harness. ", root);
                }
                try
                {
                    if (i == 0)
                    {
                        Target.UpdateUserEmail(request);
                        _writer.WriteLog(serviceName, Test_Case, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), description, SBWSCommon.StatusLevelOptions.PASS.ToString(), "Proper Response return on Test Harness. ", root);
                    }
                    else if (i == 1)
                    {
                        Target.UpdateUserEmail(request);
                        _writer.WriteLog(serviceName, Test_Case + " |ContactCrmid :" + request[0].ContactCrmId, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), description, SBWSCommon.StatusLevelOptions.PASS.ToString(), "Proper Response return on Test Harness. ", root);
                    }
                }
                catch (FaultException ex)
                {
                    _writer.WriteLog(serviceName, Test_Case, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), description, SBWSCommon.StatusLevelOptions.FAIL.ToString(), "Proper Response not return on Test Harness. | " + ex.Message, root);
                }
            }
        }
Example #2
0
        public async Task <IActionResult> UpdateUserEmail([FromBody] UpdateUserEmailRequest updateEmail)
        {
            try
            {
                await _userServices.UpdateUserEmail(updateEmail.UserId, updateEmail.Email);

                return(Ok());
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
Example #3
0
        public async Task <IActionResult> UpdateEmail([FromBody] UpdateUserEmailRequest request)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound());
            }
            var currentEmail = await _userManager.GetEmailAsync(user);

            if (currentEmail.Equals(request.Email, StringComparison.OrdinalIgnoreCase) && await _userManager.IsEmailConfirmedAsync(user))
            {
                ModelState.AddModelError(nameof(request.Email).ToLower(), _userManager.MessageDescriber.EmailAlreadyExists(request.Email));
                return(BadRequest(new ValidationProblemDetails(ModelState)));
            }
            var result = await _userManager.SetEmailAsync(user, request.Email);

            if (!result.Succeeded)
            {
                return(BadRequest(result.Errors.ToValidationProblemDetails()));
            }
            if (!_identityServerApiEndpointsOptions.Email.SendEmailOnUpdate)
            {
                return(NoContent());
            }
            if (_emailService == null)
            {
                var message = $"No concrete implementation of {nameof(IEmailService)} is registered. " +
                              $"Check {nameof(IndiceServicesServiceCollectionExtensions.AddEmailService)}, {nameof(ServiceCollectionExtensions.AddEmailServiceSmtpRazor)} or " +
                              $"{nameof(ServiceCollectionExtensions.AddEmailServiceSparkpost)} extensions on {nameof(IServiceCollection)} or provide your own implementation.";
                throw new Exception(message);
            }
            var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);

            var data = new User {
                UserName = User.FindDisplayName() ?? user.UserName
            };
            await _emailService.SendAsync(message =>
                                          message.To(user.Email)
                                          .WithSubject(_userManager.MessageDescriber.UpdateEmailMessageSubject)
                                          .WithBody(_userManager.MessageDescriber.UpdateEmailMessageBody(user, token, request.ReturnUrl))
                                          .UsingTemplate(_identityServerApiEndpointsOptions.Email.TemplateName)
                                          .WithData(data));

            return(NoContent());
        }
        public void UpdateUserEmailValid1()
        {
            string Email        = string.Empty;
            string Email1       = string.Empty;
            string ContactCrmid = string.Empty;
            string Test_Case    = "UpdateUserEmail_Validdata";
            string description  = "To verify response object for the UpdateUserEmail method.";

            UpdateUserEmailRequest[] request = null;
            //GetUserByCrmIdRequest request1 = new GetUserByCrmIdRequest();
            //GetUserByCrmIdResponse response1 = new GetUserByCrmIdResponse();
            //request1.CrmId = "";
            //response1=target.GetUserByCrmId(request1);
            //UnitTesting.UserProfile.BasicUserProfile userdetail =  response1.GetUserByCrmIdResult;
            //request1.CrmId = "CN5249505";
            DataSet data  = new DataSet();
            DataSet data1 = new DataSet();

            try
            {
                string query = "Select top 5 * from mfweb.tbl_User where IsActive = 1 and IsLocked = 0 and Password is not null and UserName like '%@ibm.com%' order by 1 desc";
                data = _Common.ExecuteDatabase(_Common.CDS_ConnectionString, query, "Select");
                if (data != null)
                {
                    ContactCrmid = data.Tables[0].Rows[0]["CRMContactId"].ToString();
                    Email        = data.Tables[0].Rows[0]["Email"].ToString();
                    request      = new UpdateUserEmailRequest[] {
                        new UpdateUserEmailRequest()
                        {
                            ContactCrmId = ContactCrmid,
                            Email        = "*****@*****.**"
                        }
                    };
                    Target.UpdateUserEmail(request);
                    string query1 = "Select  * from mfweb.tbl_User where CRMContactId ='" + ContactCrmid + "'";
                    data1 = _Common.ExecuteDatabase(_Common.CDS_ConnectionString, query1, "Select");
                    if (data1 != null)
                    {
                        Email1 = data1.Tables[0].Rows[0]["Email"].ToString();
                    }
                    else
                    {
                        _writer.WriteLog(serviceName, Test_Case, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), description, SBWSCommon.StatusLevelOptions.FAIL.ToString(), "Proper Response not return on Test Harness. ", root);
                    }
                }
                else
                {
                    _writer.WriteLog(serviceName, Test_Case, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), description, SBWSCommon.StatusLevelOptions.FAIL.ToString(), "Proper Response not return on Test Harness. ", root);
                }
                if (Email != Email1)
                {
                    _writer.WriteLog(serviceName, Test_Case + " |ContactCrmid :" + request[0].ContactCrmId + " |Email : " + Email + " |Updated Email :" + Email1, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), description, SBWSCommon.StatusLevelOptions.PASS.ToString(), "Proper Response return on Test Harness. ", root);
                    request = new UpdateUserEmailRequest[] {
                        new UpdateUserEmailRequest()
                        {
                            ContactCrmId = ContactCrmid,
                            Email        = Email
                        }
                    };
                    Target.UpdateUserEmail(request);
                }
                else
                {
                    _writer.WriteLog(serviceName, Test_Case + " |ContactCrmid :" + request[0].ContactCrmId + " |Email : " + Email + " |Updated Email :" + Email1, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), description, SBWSCommon.StatusLevelOptions.FAIL.ToString(), "Proper Response not return on Test Harness. ", root);
                }
            }
            catch (FaultException ex)
            {
                _writer.WriteLog(serviceName, "ClearEntitlementsCacheValid", DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), description, SBWSCommon.StatusLevelOptions.FAIL.ToString(), "Proper Response not return on Test Harness. | " + ex.Message, root);
            }
        }