public ActionResult Edit(Group group) { if (ModelState.IsValid) { if (group.FilePhoto != null) { var folder = "~/Content/Photos/Groups"; var name = string.Format("{0}.Jpg", group.GroupId); var response = FileHelper.UploadPhoto(group.FilePhoto, folder, name); if (response) { var pic = string.Format("{0}/{1}", folder, name); group.Photo = pic; } } try { db.Entry(group).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception) { ModelState.AddModelError(string.Empty, "Se produjo un Error a la Hora de guardar este usuario"); } } ViewBag.CourseID = new SelectList(ComboHelper.GetCourse(), "CourseId", "Title", group.CourseID); ViewBag.UserId = new SelectList(ComboHelper.GetTeacher(), "UserId", "FullName", group.UserId); return(View(group)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Group group = db.Groups.Find(id); if (group == null) { return(HttpNotFound()); } ViewBag.CourseID = new SelectList(ComboHelper.GetCourse(), "CourseId", "Title", group.CourseID); ViewBag.UserId = new SelectList(ComboHelper.GetTeacher(), "UserId", "FullName", group.UserId); return(View(group)); }
public ActionResult Create() { ViewBag.CourseID = new SelectList(ComboHelper.GetCourse(), "CourseId", "Title"); ViewBag.UserId = new SelectList(ComboHelper.GetTeacher(), "UserId", "FullName"); return(View()); }