public ActionResult ProfileView() { if (Session["UserId"] != null) { _profile = _repository.Get(Convert.ToInt32(Session["UserId"])); //Create Map var config = new MapperConfiguration(cfg => cfg.CreateMap <RestaurantAdmin, RestaurantAdminDetailsViewModel>()); var mapper = config.CreateMapper(); //Copy values RestaurantAdminDetailsViewModel restaurantAdminDetails = mapper.Map <RestaurantAdminDetailsViewModel>(_profile); if (_profile != null) { restaurantAdminDetails.Email = Session["Email"].ToString(); } return(View(restaurantAdminDetails)); } return(RedirectToAction("Index", "Login")); }
// GET: UserProfile public ActionResult Index() { if (Session["UserId"] != null) { _profile = _repository.Get(Convert.ToInt32(Session["UserId"])); //Create Map var config = new MapperConfiguration(cfg => cfg.CreateMap <RestaurantAdmin, RestaurantAdminDetailsViewModel>()); var mapper = config.CreateMapper(); //Copy values RestaurantAdminDetailsViewModel restaurantAdminDetails = mapper.Map <RestaurantAdminDetailsViewModel>(_profile); if (_profile != null) { restaurantAdminDetails.Restaurants = _restaurantRepository.GetAll() .Where(u => u.UserId == Convert.ToInt32(Session["UserId"])).ToList(); } return(View(restaurantAdminDetails)); } return(RedirectToAction("Index", "Login")); }