Ejemplo n.º 1
0
        public ActionResult EditProfileK(Kullanicilar user, HttpPostedFileBase ProfileImage)
        {
            ModelState.Remove("ModifiedUserName");
            ModelState.Remove("KimKayitEtti");
            if (ModelState.IsValid)
            {
                if (ProfileImage != null && (ProfileImage.ContentType == "image/jpeg" || ProfileImage.ContentType == "image/jpg" || ProfileImage.ContentType == "image/png"))
                {
                    string filename = $"user_{user.Id}.{ProfileImage.ContentType.Split('/')[1]}";
                    ProfileImage.SaveAs(Server.MapPath($"~/Images/{filename}"));
                    user.Resim = filename;
                }
                BusinessLayerResult <Kullanicilar> res = k.UpdateProfileK(user);
                if (res.Errors.Count > 0)
                {
                    ErrorViewModel errornotifyObj = new ErrorViewModel()
                    {
                        RedirectingUrl = "/Home/EditProfileK",
                        Title          = "Profil Güncellenemedi.",
                        Items          = res.Errors
                    };

                    return(View("Error", errornotifyObj));
                }
                Session["logink"] = res.Result;
                //CurrentSession.Set<Kullanicilar>("login", res.Result);//profil güncellendiği için sesion güncellendi
                OkViewModel notifyobj = new OkViewModel()
                {
                    Title          = "Güncelleme Başarılı",
                    RedirectingUrl = "/Home/ShowProfileK",
                };
                notifyobj.Items.Add("Güncelleme işleminiz başarılı bir şekilde gerçekleşmiştir.");

                return(View("Ok", notifyobj));
            }
            return(View(user));
        }