public async Task <IActionResult> Register(RegisterViewModel registerViewModel, CustomerProfiles customer) { var user = registerViewModel.UserDto; if (registerViewModel.UserDto.UserType == 2 && registerViewModel.UserDto.UserName != null && registerViewModel.UserDto.Password != null) { customer.CustomerEmail = user.UserName; customer.CustomerFullName = "not set"; customer.CustomerPhone = "not set"; customer.CustomerGender = "Not set"; customer.CustomerAddress = "not set"; customer.CustomerDOB = DateTime.Today; customer.CustomerType = "Normal"; customer.CustomerActive = true; customer.CreatedBy = "System"; customer.CreatedTime = DateTime.Now; customer.LastUpdatedBy = "System"; customer.LastUpdatedTime = DateTime.Now; customer.VersionNo = 1; customer.IsDeleted = false; customer.PostalCode = "not set"; customer.Region = "not set"; string insertCustomerData = await _customerProfileService.CreateCustomer(customer); } User result = await _loginService.RegisterAsync(user); if (result != null) { HttpContext.Session.SetInt32("usertype", result.UserType); HttpContext.Session.SetInt32("userid", result.UserId); HttpContext.Session.SetString("username", result.UserName); if (result.UserType == 1) { await _shopProfileService.InsertAsync(new ShopProfile { UserId = result.UserId }); return(Redirect("/PromotionByShopId")); } else { return(Redirect("/PromotionByRecommendation")); } } ModelState.AddModelError("Register Failed", "Register Failed"); return(View()); }
public async Task <IActionResult> InsertCustomerProfile(CustomerProfileViewModel customerProfileViewModel) { CustomerProfiles customer = customerProfileViewModel.customerDto; customer.CustomerType = "Normal"; customer.CustomerActive = true; customer.CreatedBy = "System"; customer.CreatedTime = DateTime.Now; customer.LastUpdatedBy = "System"; customer.LastUpdatedTime = DateTime.Now; customer.VersionNo = 1; customer.IsDeleted = false; string result = await _customerProfileService.CreateCustomer(customer); return(View("SuccessCustomerClick", customerProfileViewModel)); }