Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
        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"));
        }
Exemplo n.º 3
0
        public ActionResult DetailUniversity(Guid id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var university = new UniversityDao().FindById(id);

            return(View(university));
        }
Exemplo n.º 4
0
        // GET: Admin/University
        public ActionResult Index()
        {
            var model = new UniversityDao().ListUniversities();

            return(View(model));
        }