Below is the code
以下是代码
[Route("users/{userid}/create")]
public ActionResult CreateSellerProfile(string userId)
{
var country = _locationService.GetCountries().ToDictionary(x => x.Id, x => x.CountryName);
var model = new SellerProfileViewModel { CountryDic = country };
model.UserId = userId;
return View(model);
}
[Authorize]
[HttpPost]
[Route("users/create")]
public ActionResult CreateSellerProfile(SellerProfileViewModel model)
{
if (!ModelState.IsValid)
{
model.StateDic = _locationService.Getstates(model.CountryId).ToDictionary(x => x.Id, x => x.StateName);
model.CountryDic = _locationService.GetCountries().ToDictionary(x => x.Id, x => x.CountryName);
return View(model);
}
var checkForalreadyExists = _userService.GetSellerProfileByUserId(model.UserId);
if (checkForalreadyExists == null)
{
var domainSellerObj = Mapper.Map<SellerProfileViewModel, SellerProfile>(model);
_userService.SaveSellerProfile(domainSellerObj);
return RedirectToAction("CreateSellerProfile", new { model.UserId });
}
else
{
SetMessage(MessageType.Danger, MessageConstant.GetMessage(Messages.SellerProfileAdded));
return RedirectToAction("CreateSellerProfile", new { model.UserId });
}
}
[Route("users/{