Exemple #1
0
        public async Task<ActionResult> Register([FromBody]CustomerRegisterVM registerVM)
        {
            try
            {
                var user = new MyUser()
                {
                    UserName = registerVM.Username,
                    Email = registerVM.Email,
                    FullName = registerVM.Fullname,
                    IsActive = true,
                    IsCustomer = true,
                    DateCreated = DateTime.Now
                };
                var resultUser = await _userManager.CreateAsync(user, registerVM.Password);
                var resultRole = await _userManager.AddToRoleAsync(user, nameof(UserRoles.Customer));
                if (resultUser.Succeeded && resultRole.Succeeded)
                {
                    return Ok();
                }
                else
                {
                    return BadRequest(resultUser.Errors + " \n" + resultRole.Errors);
                }

            }
            catch (Exception e)
            {
                return BadRequest(e.Message);
            }
        }
Exemple #2
0
        public async Task <HttpResponseMessage> Register(CustomerRegisterVM customerRegisterVM)
        {
            _logger.LogInformation($"SAGA - customerRegisterVM : {JsonConvert.SerializeObject(customerRegisterVM)}");
            var customer = Mapper.Map <Customer>(customerRegisterVM);

            HttpResponseMessage httpResponse = await Post(customer, "customer/register");

            _logger.LogInformation($"SAGA - httpResponse : {JsonConvert.SerializeObject(httpResponse)}");
            string emailAddress = httpResponse.Content.ReadAsStringAsync().Result;

            return(httpResponse);
        }