Пример #1
0
        // GET: 客戶專區
        public ActionResult Index()
        {
            var data = repo客戶資料.Find(Convert.ToInt32(User.Identity.Name));

            Mapper.Initialize(cfg => cfg.CreateMap <客戶資料, 客戶專區_資料修改VM>());
            客戶專區_資料修改VM model = Mapper.Map <客戶專區_資料修改VM>(data);

            model.密碼 = "";
            return(View(model));
        }
        public ActionResult Index(客戶專區_資料修改VM item)
        {
            if (ModelState.IsValid)
            {
                var data = repo.Find(Convert.ToInt32(User.Identity.Name));

                Mapper.Initialize(cfg => cfg.CreateMap <客戶專區_資料修改VM, 客戶資料>());
                Mapper.Map(item, data, typeof(客戶專區_資料修改VM), typeof(客戶資料));

                if (!string.IsNullOrEmpty(data.密碼))
                {
                    data.密碼進行雜湊();
                }
                repo.UnitOfWork.Commit();

                return(RedirectToAction("Index", "Home"));
            }
            return(View());
        }