Exemple #1
0
        public IActionResult Profile(UserViewModel model)
        {
            bool CheckUsername = _settingRepository.CheckUserName(_user.Id, "d/" + model.Username);

            if (CheckUsername)
            {
                ModelState.AddModelError("Username", "Bu istifadəçi adı artıq mövcuddur");
            }
            bool CheckEmail = _settingRepository.CheckEmail(_user.Id, model.Email);

            if (CheckEmail)
            {
                ModelState.AddModelError("Email", "Bu Email artıq mövcuddur");
            }

            if (ModelState.IsValid)
            {
                var user = _mapper.Map <UserViewModel, User>(model);

                var userToUpdate = _user;

                _settingRepository.UpdateUser(user, userToUpdate);



                return(RedirectToAction("profile"));
            }



            return(View(model));
        }