Exemplo n.º 1
0
        public async Task <IActionResult> ProfilimiGoster(UserProfilEditViewModel model)
        {
            var kullanici = await userManager.FindByIdAsync(model.Id);

            if (kullanici == null)
            {
                ViewBag.ErrorMessage = $"{model.Id} id'li hesap bulunamadı.";
                return(View("SayfaBulunamadi"));
            }
            else
            {
                kullanici.UserName = model.UserName;
                kullanici.Sinif    = model.Class;

                var sonuc = await userManager.UpdateAsync(kullanici);

                if (sonuc.Succeeded)
                {
                    return(RedirectToAction("ProfilimiGoster"));
                }

                foreach (var error in sonuc.Errors)
                {
                    ModelState.AddModelError("", error.Description);
                }
                return(View(model));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> ProfilimiGoster(string id)
        {
            var kullanici = await userManager.FindByIdAsync(id);

            if (kullanici == null)
            {
                ViewBag.ErrorMessage = "Hesabınız bulunamadı.";
                return(View("SayfaBulunamadi"));
            }

            var model = new UserProfilEditViewModel
            {
                Id       = kullanici.Id,
                UserName = kullanici.UserName,
                Class    = kullanici.Sinif
            };

            return(View(model));
        }