public ActionResult DeleteConfirmed(int id) { MarktUser marktUser = marktUserManager.Find(x => x.Id == id); marktUserManager.Delete(marktUser); return(RedirectToAction("Index")); }
public string GetCurrentUsername() { MarktUser user = CurrentSession.User; if (user != null) { return(user.Username); } else { return("system"); } }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MarktUser evernoteUser = marktUserManager.Find(x => x.Id == id.Value); if (evernoteUser == null) { return(HttpNotFound()); } return(View(evernoteUser)); }
public ActionResult Edit(MarktUser evernoteUser) { ModelState.Remove("CreatedOn"); ModelState.Remove("ModifiedOn"); ModelState.Remove("ModifiedUsername"); if (ModelState.IsValid) { BusinessLayerResult <MarktUser> res = marktUserManager.Update(evernoteUser); if (res.Errors.Count > 0) { res.Errors.ForEach(x => ModelState.AddModelError("", x.Message)); return(View(evernoteUser)); } return(RedirectToAction("Index")); } return(View(evernoteUser)); }
public ActionResult EditProfile(MarktUser model, 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_{model.Id}.{ProfileImage.ContentType.Split('/')[1]}"; ProfileImage.SaveAs(Server.MapPath($"~/images/{filename}")); model.ProfileImageFilename = filename; } BusinessLayerResult <MarktUser> res = marktUserManager.UpdateProfile(model); if (res.Errors.Count > 0) { ErrorViewModel errorNotifyObj = new ErrorViewModel() { Items = res.Errors, Title = "Profil Güncellenemedi.", RedirectingUrl = "/Home/EditProfile" }; return(View("Error", errorNotifyObj)); } CurrentSession.Set <MarktUser>("login", res.Result); return(RedirectToAction("ShowProfile")); } return(View(model)); }