예제 #1
0
 public ActionResult EditProfile(EverNoteUser user, HttpPostedFileBase ProfileImage)
 {
     ModelState.Remove("ModifiedUserName");
     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.ProfilImageFileName = fileName;
         }
         EverNoteUserManager eum = new EverNoteUserManager();
         BusinessLayerResult <EverNoteUser> res = eum.UpdateProfile(user);
         if (res.Errors.Count > 0)
         {
         }
         Session["login"] = res.Result;
         return(RedirectToAction("ShowProfile"));
     }
     return(View(user));
 }
예제 #2
0
        public ActionResult EditProfile(EvernoteUser model, HttpPostedFileBase ProfileImage)
        {
            ModelState.Remove("ModifiedUsername"); // kontrolden kaldırıyor

            if (ModelState.IsValid)
            {
                if (ProfileImage != null && (ProfileImage.ContentType == "image/jpeg" ||
                                             ProfileImage.ContentType == "image/jpg" ||
                                             ProfileImage.ContentType == "image/png"))
                {
                    string filename = $"user_{model.Id}.{ProfileImage.ContentType.Split('/')[1]}";
                    ProfileImage.SaveAs(Server.MapPath($"~/images/{filename}"));
                    model.ProfileImageFilename = filename;
                }

                BusinessLayerResult <EvernoteUser> res = everNoteUserManager.UpdateProfile(model);

                if (res.Erros.Count > 0)
                {
                    ErrorViewModel errorNotifyObj = new ErrorViewModel()
                    {
                        Items          = res.Erros,
                        Title          = "Profil Güncellenemedi.",
                        RedirectingUrl = "/Home/EditProfile"
                    };
                    return(View("Error", errorNotifyObj));
                }

                //Session["login"] = res.Result;

                CurrentSession.Set <EvernoteUser>("login", res.Result);

                return(RedirectToAction("ShowProfile"));
            }

            return(View(model));
        }