public ActionResult Page(string name) { bool isAllowable = false; if (User.IsInRole("Admin")) { isAllowable = true; } else { if (name == User.Identity.GetUserName()) { isAllowable = true; } } if (isAllowable) { EditUserViewModelPanel user = applicationUser.Get(name); if (applicationUser.Result.Type != ResultType.Success) { TempData["result"] = applicationUser.Result; return(RedirectToAction("List")); } return(View(user)); } return(RedirectToAction("Index", "Home", new { area = "" })); }
public ActionResult Page(EditUserViewModelPanel model, HttpPostedFileBase ProfileImage) { if (ModelState.IsValid) { // Kullanıcı fotoğraf kontrolü if (ProfileImage != null) { string profileImage = model.Image; if (System.IO.File.Exists(Server.MapPath("~/Images/" + profileImage)) && profileImage != "avatar.jpg") { System.IO.File.Delete(Server.MapPath("~/Images/" + profileImage)); } profileImage = ProfileImage.FileName.Substring(0, ProfileImage.FileName.Length - 4) + Guid.NewGuid().ToString() + ProfileImage.FileName.Substring(ProfileImage.FileName.Length - 4, 4); WebImage img = new WebImage(ProfileImage.InputStream); img.Resize(270, 340, true, false); img.Save(Path.Combine(Server.MapPath(@"~/Images"), Path.GetFileName(profileImage))); model.Image = profileImage; } applicationUser.Edit(model); TempData["result"] = applicationUser.Result; } return(Page(model.UserName)); }