Ejemplo n.º 1
0
        public ActionResult Edit()
        {
            if (Session["UserId"] != null)
            {
                _profile = _repository.Get(Convert.ToInt32(Session["UserId"]));

                var config = new MapperConfiguration(cfg => cfg.CreateMap <RestaurantAdmin, RestaurantAdminEditViewModel>());
                var mapper = config.CreateMapper();
                //Copy values

                RestaurantAdminEditViewModel restaurantAdminEditViewModel = mapper.Map <RestaurantAdminEditViewModel>(_profile);

                return(View(restaurantAdminEditViewModel));
            }

            return(RedirectToAction("Index", "Login"));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(RestaurantAdminEditViewModel input)
        {
            if (Session["UserId"] != null)
            {
                _profile = _repository.Get(Convert.ToInt32(Session["UserId"]));

                var config = new MapperConfiguration(cfg => cfg.CreateMap <RestaurantAdminEditViewModel, RestaurantAdmin>());
                var mapper = config.CreateMapper();
                //Copy values

                RestaurantAdmin userProfile = mapper.Map <RestaurantAdmin>(input);
                userProfile.UserId = Convert.ToInt32(Session["UserId"]);

                _repository.Update(userProfile);


                return(RedirectToAction("Index"));
            }

            return(RedirectToAction("Index", "Login"));
        }