public ActionResult Create() { ViewBag.CategoryId = new SelectList(Cache_Helper.GetCategoriesFromCache(), "Id", "Title"); return(View()); }
public ActionResult Create(Note note, HttpPostedFileBase ProfileImage) { ModelState.Remove("CreatedOn"); ModelState.Remove("ModifiedUserName"); ModelState.Remove("ModifiedOn"); if (ModelState.IsValid) { if (ProfileImage != null && (ProfileImage.ContentType == "image/jpeg" || ProfileImage.ContentType == "image/jpg" || ProfileImage.ContentType == "image/png")) { string filename = $"user_{note.Id}.{ProfileImage.ContentType.Split('/')[1]}"; ProfileImage.SaveAs(Server.MapPath($"~/Images/{filename}")); note.NoteImageFilename = filename; } note.Owner = CurrentSession.CurrentUser; noteManager.Insert(note); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(Cache_Helper.GetCategoriesFromCache(), "Id", "Title", note.CategoryId); return(View(note)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Note note = noteManager.Find(x => x.Id == id.Value); if (note == null) { return(HttpNotFound()); } ViewBag.CategoryId = new SelectList(Cache_Helper.GetCategoriesFromCache(), "Id", "Title", note.CategoryId); return(View(note)); }