예제 #1
0
        public ActionResult Create([Bind(Include = "id,author,description,showimage,coverimage,typeid,resourceaddress,name")] Exhibition exhibition,
                                   HttpPostedFileBase file, HttpPostedFileBase picture)
        {
            //var filePath = Server.MapPath(path);
            if (customService.SaveFile(file))
            {
                exhibition.resourceaddress = file.FileName;
            }
            if (picture != null)
            {
                string ExtName = Path.GetExtension(picture.FileName).ToLower();
                if (ExtName != ".jpg" && ExtName != ".jpeg" && ExtName != ".png" && ExtName != ".gif")
                {
                    return(Content("图片格式不正确,只允许上传jpg,png,gif!" +
                                   "<a href=#' onClick='javascript :history.back(-1);'>返回</a>"));
                }
                customService.SaveFile(picture);
                exhibition.showimage = picture.FileName;
            }

            if (ModelState.IsValid)
            {
                exhibitionService.AddExhibition(exhibition);
                return(RedirectToAction("Index"));
            }

            return(View(exhibition));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "id,name,description,address,typeid,time")] Resource resource, HttpPostedFileBase file)
        {
            if (customService.SaveFile(file))
            {
                resource.address = file.FileName;
                resource.time    = DateTime.Now;
            }
            if (ModelState.IsValid)
            {
                resourceService.AddResource(resource);
                return(RedirectToAction("Index"));
            }

            return(View(resource));
        }
예제 #3
0
        public ActionResult Create([Bind(Include = "id,resourceAddress,key,image,title,code,context,result")] Instance instance,
                                   HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (customService.SaveFile(file))
                {
                    instance.resourceAddress = file.FileName;
                }
                instanceService.AddInstance(instance);
                return(RedirectToAction("Index"));
            }

            return(View(instance));
        }
예제 #4
0
        public ActionResult Create([Bind(Include = "id,image,key,resourceAddress,description,context")] Knowledge knowledge,
                                   HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (customService.SaveFile(file))
                {
                    knowledge.resourceAddress = file.FileName;
                }
                knowledgeService.AddKnowLedge(knowledge);
                return(RedirectToAction("Index"));
            }

            return(View(knowledge));
        }
예제 #5
0
        public ActionResult ConfirmAddKnowledge([Bind(Include = "id,name,description,address,typeid,time")] Resource resource,
                                                HttpPostedFileBase file, string ak)
        {
            var id = ak;

            if (customService.SaveFile(file))
            {
                resource.address = file.FileName;
            }
            if (ModelState.IsValid)
            {
                advanceKnowledgeService.AddRelevantResource(resource, int.Parse(ak));
                return(RedirectToAction("Details/" + ak));
            }
            return(View(resource));
        }
예제 #6
0
 public ActionResult Create([Bind(Include = "id,name,description,address,typeid,time")] Resource resource, HttpPostedFileBase file)
 {
     if (customService.SaveFile(file))
     {
         resource.address = file.FileName;
     }
     if (ModelState.IsValid)
     {
         resource.time = DateTime.Now;
         resourceService.AddResource(resource);
         var id = Request.Cookies["id"].Value.ToString();
         uploadRecordForTeacherService.AddUploadRecordForTeachers(
             new UploadRecordForTeacher()
         {
             sourceId = resource.id, userId = int.Parse(id)
         });
         return(RedirectToAction("Index/" + id));
     }
     return(View(resource));
 }