public ActionResult CreatUniversity(University university, HttpPostedFileBase logo) { if (logo != null && logo.ContentLength > 0) { logo.InputStream.Read(new byte[logo.ContentLength], 0, logo.ContentLength); string fileName = System.IO.Path.GetFileName(logo.FileName); string urlImage = Server.MapPath("~/Assets/Admin/Img/University/" + logo.FileName); logo.SaveAs(urlImage); university.UniversityLogo = "Assets/Admin/Img/University/" + logo.FileName; } if (ModelState.IsValid) { var check = new UniversityDao().InsertUniversity(university); if (check) { return(RedirectToAction("Index", "University")); } else { ModelState.AddModelError("", "Creat university failed!"); } } return(View("Index")); }
public ActionResult CreatUniversity(University university, HttpPostedFileBase UniversityLogo) { var file = UniversityLogo; if (file != null) { var fileName = Path.GetFileName(file.FileName); var extention = Path.GetExtension(file.FileName); var filenamewithoutextension = Path.GetFileNameWithoutExtension(file.FileName); file.SaveAs(Server.MapPath("/Assets/Admin/Img/University/" + fileName)); var srcImage = "/Assets/Admin/Img/University/" + fileName; university.UniversityLogo = srcImage; } if (ModelState.IsValid) { var check = new UniversityDao().InsertUniversity(university); if (check) { return(RedirectToAction("Index", "University")); } else { ModelState.AddModelError("", "Creat university failed!"); } } return(View("Index")); }
public ActionResult DetailUniversity(Guid id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var university = new UniversityDao().FindById(id); return(View(university)); }
// GET: Admin/University public ActionResult Index() { var model = new UniversityDao().ListUniversities(); return(View(model)); }