Пример #1
0
        public ActionResult Edit([Bind(Include = "ID,Link,Title,Status,CatId,Description,CreateDate,Thumbnail")] TutorialVideo tutorialVideo)
        {
            if (ModelState.IsValid)
            {
                if (Request.Files.Count > 0)
                {
                    var uploadFile = Request.Files[0];
                    if (uploadFile.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(uploadFile.FileName);
                        fileName = Guid.NewGuid() + Path.GetExtension(fileName);
                        var file_src = Path.Combine(Server.MapPath("~/photo/Uploads/"), fileName);
                        tutorialVideo.Thumbnail = fileName;

                        uploadFile.SaveAs(file_src);
                    }
                }

                db.Entry(tutorialVideo).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            SetCatInfo();
            return(View(tutorialVideo));
        }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            TutorialVideo tutorialVideo = db.TutorialVideos.Find(id);

            db.TutorialVideos.Remove(tutorialVideo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
        // GET: ttn_content/TutorialVideo/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TutorialVideo tutorialVideo = db.TutorialVideos.Find(id);

            if (tutorialVideo == null)
            {
                return(HttpNotFound());
            }
            return(View(tutorialVideo));
        }
Пример #4
0
 public TutorialVideoViewModel(
     IConfiguration config,
     TutorialVideo tutorialVideo,
     int customisationId,
     int sectionId,
     int tutorialId
     )
 {
     CustomisationId = customisationId;
     SectionId       = sectionId;
     TutorialId      = tutorialId;
     TutorialName    = tutorialVideo.TutorialName;
     SectionName     = tutorialVideo.SectionName;
     CourseTitle     = tutorialVideo.CourseTitle;
     VideoPath       = ContentUrlHelper.GetContentPath(config, tutorialVideo.VideoPath);
 }
Пример #5
0
        public ActionResult ShowContent(int?id)
        {
            ViewBag.Facebook  = db.Settings.FirstOrDefault(t => t.Id == 2).Value;
            ViewBag.Youtube   = db.Settings.FirstOrDefault(t => t.Id == 3).Value;
            ViewBag.Linked    = db.Settings.FirstOrDefault(t => t.Id == 6).Value;
            ViewBag.Gplus     = db.Settings.FirstOrDefault(t => t.Id == 5).Value;
            ViewBag.Instagram = db.Settings.FirstOrDefault(t => t.Id == 4).Value;

            ViewBag.Hotline = db.Settings.FirstOrDefault(t => t.Id == 1).Value;
            ViewBag.Address = db.Settings.FirstOrDefault(t => t.Key == "address").Value;
            ViewBag.Phone   = db.Settings.FirstOrDefault(t => t.Key.Equals("phone")).Value;
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TutorialVideo tutorialVideo = db.TutorialVideos.Find(id);

            if (tutorialVideo == null)
            {
                return(HttpNotFound());
            }
            return(View("~/Areas/ttn_content/Views/TutorialVideo/ShowContent.cshtml", tutorialVideo));
        }
Пример #6
0
        public ActionResult Create([Bind(Include = "Link,Title,Status,CatId,Description")] TutorialVideo tutorialVideo, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                if (Request.Files.Count > 0)
                {
                    var uploadFile = Request.Files[0];

                    var fileName = Path.GetFileName(uploadFile.FileName);
                    fileName = Guid.NewGuid() + Path.GetExtension(fileName);
                    var file_src = Path.Combine(Server.MapPath("~/photo/Uploads/"), fileName);
                    tutorialVideo.Thumbnail  = fileName;
                    tutorialVideo.CreateDate = DateTime.Now;
                    uploadFile.SaveAs(file_src);
                }

                db.TutorialVideos.Add(tutorialVideo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            SetCatInfo();

            return(View(tutorialVideo));
        }