bhavkam

create seller profile

Feb 5th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 1.83 KB | None | 0 0
  1.         [Route("users/{userid}/create")]
  2.        public ActionResult CreateSellerProfile(string userId)
  3.        {
  4.            var country = _locationService.GetCountries().ToDictionary(x => x.Id, x => x.CountryName);
  5.            var model = new SellerProfileViewModel { CountryDic = country };
  6.            model.UserId = userId;
  7.            return View(model);
  8.        }
  9.        [Authorize]
  10.  
  11.        [HttpPost]
  12.  
  13.        [Route("users/create")]
  14.        public ActionResult CreateSellerProfile(SellerProfileViewModel model)
  15.        {
  16.          if (!ModelState.IsValid)
  17.            {
  18.                model.StateDic = _locationService.Getstates(model.CountryId).ToDictionary(x => x.Id, x => x.StateName);
  19.                    
  20.                model.CountryDic = _locationService.GetCountries().ToDictionary(x => x.Id, x => x.CountryName);
  21.                return View(model);
  22.            }
  23.  
  24.            
  25.  
  26.            var checkForalreadyExists = _userService.GetSellerProfileByUserId(model.UserId);
  27.            if (checkForalreadyExists == null)
  28.            {
  29.                var domainSellerObj = Mapper.Map<SellerProfileViewModel, SellerProfile>(model);
  30.                _userService.SaveSellerProfile(domainSellerObj);
  31.  
  32.              return RedirectToAction("CreateSellerProfile", new { model.UserId });
  33.                
  34.            }
  35.            else
  36.            {
  37.                SetMessage(MessageType.Danger, MessageConstant.GetMessage(Messages.SellerProfileAdded));
  38.  
  39.          return RedirectToAction("CreateSellerProfile", new { model.UserId });
  40.                
  41.            }
  42.        }
  43.        
  44. //I want to ask that after we do POST to this action CreateSellerProfile,
  45. //then we want to redirect again to the same action CreateSellerProfile empty page,
  46. //we are facing the problem that it's not able to find the route that we defined i.e [Route("users/{userid}/create")]
Add Comment
Please, Sign In to add comment