Exemple #1
0
        public ActionResult AccPartial()
        {
            var restaurant = memberService.GetRestaurant(Request.Cookies["idCookie"].Values["r_id"]);
            var accVM      = new RestaurantAccountViewModel();

            Mapper.Map(restaurant, accVM);
            accVM.R_Password = string.Empty;
            return(PartialView("_AccountPartial", accVM));
        }
Exemple #2
0
        /// <summary>
        /// 儲存修改後餐廳帳號資料
        /// </summary>
        /// <param name="r_AccountVM"></param>
        /// <returns></returns>
        public ActionResult SaveAccount(RestaurantAccountViewModel r_AccountVM)
        {
            var _R_AccountVM = new RestaurantAccountViewModel()
            {
                R_Account = memberService.GetRestaurant(User.Identity.Name).R_Account
            };

            if (!ModelState.IsValid)
            {
                return(View("Info", _R_AccountVM));
            }

            var checkPassword = memberService.LoginCheck(User.Identity.Name, r_AccountVM.R_Password);

            if (!string.IsNullOrWhiteSpace(checkPassword))
            {
                ModelState.AddModelError("R_Password", "舊密碼有誤,請重新再試一次");
                return(View("Info", _R_AccountVM));
            }

            var restaurant = memberService.GetRestaurant(User.Identity.Name);

            restaurant.R_Password = memberService.HashPassword(r_AccountVM.new_R_Password);
            var result = memberService.Update(restaurant);

            if (result.Success)
            {
                TempData["Messageacc"] = "bootbox.alert('密碼已成功儲存,下次請以新密碼登入');";
                TempData["classColor"] = "green";
            }
            else
            {
                TempData["Messageacc"] = "bootbox.alert('儲存失敗');";
                TempData["classColor"] = "red";
            }
            return(RedirectToAction("Info"));
        }