Ejemplo n.º 1
0
        public ActionResult ChangeCounselor(UserCounselorViewModel model)
        {
            if (ModelState.IsValid)
            {
                string userId     = User.Identity.GetUserId();
                bool   editResult = _userManager.ChangeUserCounselor(userId, model.CounselorFirstName, model.CounselorLastName);

                if (editResult)
                {
                    return(RedirectToAction("Index", new { Message = ManageMessageId.ChangeCounselorDataSuccess }));
                }
                else if (_userManager.AddUserCounselot(userId, model.CounselorFirstName, model.CounselorLastName))
                {
                    return(RedirectToAction("Index", new { Message = ManageMessageId.ChangeCounselorDataSuccess }));
                }
                else
                {
                    return(RedirectToAction("Index", new { Message = ManageMessageId.Error }));
                }
            }
            else
            {
                return(View(model));
            }
        }
Ejemplo n.º 2
0
        public ActionResult ChangeCounselor()
        {
            var dbModel = _userManager.GetUserCounselorById(User.Identity.GetUserId());
            UserCounselorViewModel viewModel;

            if (dbModel != null)
            {
                viewModel = new UserCounselorViewModel
                {
                    CounselorFirstName = dbModel.FirstName,
                    CounselorLastName  = dbModel.LastName
                };
            }
            else
            {
                viewModel = new UserCounselorViewModel();
            }

            return(View(viewModel));
        }