public static MainViewModel BuildMainView() { MainViewModel MVM = new MainViewModel(); MVM.Faqs = FAQsRoutines.GetTopFAQsForMAin(); MVM.Courses = CourseRoutine.GetTopCoursesForMAin(); MVM.Gallary = GalleryController.GetActiveGallary(); MVM.Instarctors = InstractorsRoutines.GetAll(); return(MVM); }
public ActionResult Edit([Bind(Include = "ID,Instractor_EngName,Instractor_AraName,instractor_imagePath,,ImageUpload,Instractor_Address,Instractor_Mobile," + "Instractor_phone,Instractor_Email,Instractor_Facebook,instractor_twitter,Instractor_LinkedIn,Instractor_StatusID,Instractor_GenderID,Instractor_Birthdate,instractor_QualificationsEnglish")] Instractors instractors) { if (ModelState.IsValid) { string oldimagepath = ""; using (CenterDBEntities db = new CenterDBEntities()) { oldimagepath = db.Instractors.Where(x => x.ID == instractors.ID).SingleOrDefault().instractor_imagePath; } using (CenterDBEntities db = new CenterDBEntities()) { if (instractors.ImageUpload != null && !string.IsNullOrEmpty(instractors.ImageUpload.FileName)) { string subPath = "~/Uploads/Photo/instractors/"; var filename = Path.GetFileName(instractors.ImageUpload.FileName); var formattedFileName = string.Format("{0}-{1}{2}" , instractors.Instractor_EngName , instractors.ID , Path.GetExtension(filename)); bool exists = System.IO.Directory.Exists(subPath); if (!exists) { System.IO.Directory.CreateDirectory(Server.MapPath("~/Uploads/Photo/instractors/")); } subPath = Path.Combine("~/Uploads/Photo/instractors/", formattedFileName); var path = Server.MapPath(subPath); instractors.ImageUpload.SaveAs(path); instractors.instractor_imagePath = subPath; } else { instractors.instractor_imagePath = oldimagepath; } db.Entry(instractors).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } ViewBag.Instractor_GenderID = UImanger.GenderDll(); ViewBag.Instractor_StatusID = InstractorsRoutines.GetInstractorStatusDLL(); return(View(instractors)); }
// GET: Instractor/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } using (CenterDBEntities db = new CenterDBEntities()) { Instractors instractors = db.Instractors.Find(id); if (instractors == null) { return(HttpNotFound()); } ViewBag.Instractor_GenderID = UImanger.GenderDll(); ViewBag.Instractor_StatusID = InstractorsRoutines.GetInstractorStatusDLL(); return(View(instractors)); } }
// GET: Instractor/Create public ActionResult Create() { ViewBag.Instractor_GenderID = UImanger.GenderDll(); ViewBag.Instractor_StatusID = InstractorsRoutines.GetInstractorStatusDLL(); return(View()); }