public ActionResult Edit([Bind(Include = "RoleID,RoleName")] tb_Roles tb_Roles) { if (ModelState.IsValid) { db.Entry(tb_Roles).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tb_Roles)); }
public ActionResult Edit([Bind(Include = "MemberNotesID,MemberID,Notes,NoteTypeID,NoteDate,TakenBy,AddedBy,AddedDateTime,ModifiedBy,ModifiedDateTime")] tb_MemberNotes tb_MemberNotes) { if (ModelState.IsValid) { db.Entry(tb_MemberNotes).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.NoteTypeID = new SelectList(db.tb_NoteType, "NoteTypeID", "NoteType", tb_MemberNotes.NoteTypeID); ViewBag.MemberID = new SelectList(db.tb_MemberMaster, "MemberID", "LastName", tb_MemberNotes.MemberID); return(View(tb_MemberNotes)); }
public ActionResult Edit([Bind(Include = "SemesterTaughtID,SemesterRecID,MemberID,RoomID,ClassID,ClassStart,ClassEnd,ClassWeekDayID")] tb_SemesterTaught tb_SemesterTaught) { if (ModelState.IsValid) { db.Entry(tb_SemesterTaught).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } //ViewBag.ClassID = new SelectList(db.tb_Class, "ClassID", "ClassName", tb_SemesterTaught.ClassID); ViewBag.SemesterRecID = new SelectList(db.tb_Semesters, "SemesterRecID", "FiscalYear", tb_SemesterTaught.SemesterRecID); //ViewBag.RoomID = new SelectList(db.tb_Room, "RoomID", "RoomName", tb_SemesterTaught.RoomID); ViewBag.ClassWeekDayID = new SelectList(db.tb_WeekDay, "ClassWeekDayID", "WeekDayName", tb_SemesterTaught.ClassWeekDayID); ViewBag.MemberID = new SelectList(db.tb_MemberMaster, "MemberID", "MemberIDNumber", tb_SemesterTaught.MemberID); return(View(tb_SemesterTaught)); }
public ActionResult Edit([Bind(Include = "BuildingID,BuildingName,CampusID,ImagePath")] tb_Building model, HttpPostedFileBase file) { ViewBag.CampusID = new SelectList(db.tb_Campus, "CampusID", "CampusName", model.CampusID); bool isFileSelected = false; if (file != null && file.ContentLength > 0) { try { var extension = file.FileName.Split('.').Last().ToUpper(); if (extension != "PDF" && extension != "JPG") { ViewBag.Message = "Selected file type is not PDF or JPEG"; return(View(model)); } string path = Path.Combine(Server.MapPath(MvcApplication.BuildingsFolder), file.FileName); file.SaveAs(path); ViewBag.Message = "File uploaded successfully"; isFileSelected = true; } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); return(View(model)); } } //else //{ // ViewBag.Message = "You have not specified a file"; // return View(model); //} if (ModelState.IsValid) { if (isFileSelected) { model.ImagePath = file.FileName; } db.Entry(model).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }