Esempio n. 1
0
        public ActionResult EditTutorial(TutorialsModel FormData)
        {
            HttpPostedFileBase   DP            = FormData.Doc;
            TutorialsDataContext UploadContext = new TutorialsDataContext();
            var file = "";
            var path = Request.PhysicalApplicationPath;

            if (DP != null && (DP.ContentLength <= 10240000 && DP.ContentType == "application/docx" || DP.ContentType == "application/pdf" || DP.ContentType == "text/plain"))
            {
                file = DP.FileName;

                if (!Directory.Exists(path + "Uploads"))
                {
                    Directory.CreateDirectory(path + "Uploads");
                }
                if (System.IO.File.Exists(DP.FileName))
                {
                    System.IO.File.Move(DP.FileName, DP.FileName + "old");
                }
                DP.SaveAs(path + "Uploads/" + DP.FileName);
            }
            else
            {
                file = FormData.DocName;
            }
            UploadContext.EditTutorial(Session["UserID"], FormData.TutorialsID, file, path, FormData.Subject, FormData.Category, FormData.Description);
            return(RedirectToAction("Index", "Tutorials"));
        }
        public ActionResult RemoveFavourite(int TutorialsID)
        {
            ViewTutorialsDataContext loTutorialContext = new ViewTutorialsDataContext();
            TutorialsModel           loTutorial        = new TutorialsModel();

            loTutorialContext.RemoveFavourite(TutorialsID, Convert.ToDecimal(Session["UserID"]));
            return(RedirectToAction("Index"));
        }
        public ActionResult SearchTutorials(string Keywords, string Subject = null, string Category = null)
        {
            ViewTutorialsDataContext loTutorialContext = new ViewTutorialsDataContext();
            TutorialsModel           loUpload          = new TutorialsModel();

            loUpload.loTutorialsData = loTutorialContext.SearchTutorials((Keywords == "")?null:Keywords);
            return(View("~/Areas/Users/Views/SearchTutorials/_Search.cshtml", loUpload));
        }
Esempio n. 4
0
        public ActionResult DelTutorials(decimal TutorialsID)
        {
            TutorialsDataContext UploadContext = new TutorialsDataContext();
            TutorialsModel       lotutorials   = new TutorialsModel();

            lotutorials.loTutorialsData = UploadContext.DelTutorial(TutorialsID);
            return(View("~/Areas/Admin/Views/Tutorials/_GetTutorialsBySearch.cshtml", lotutorials));
        }
Esempio n. 5
0
        // GET: Admin/Tutorials
        public ActionResult Index()
        {
            AdminDataContext dbContext   = new AdminDataContext();
            TutorialsModel   loTutorials = new TutorialsModel();

            loTutorials.loTutorialsData = dbContext.GetTutorials();
            return(View("Tutorials", loTutorials));
        }
        // GET: Users/SearchTutorials
        public ActionResult Index()
        {
            ViewTutorialsDataContext loTutorialContext = new ViewTutorialsDataContext();
            TutorialsModel           loTutorial        = new TutorialsModel();

            loTutorial.loTutorialsHistory = loTutorialContext.TutorialHistory(Convert.ToDecimal(Session["UserID"]));
            loTutorial.loTutorialsData    = loTutorialContext.TutorialHistory(Convert.ToDecimal(Session["UserID"]), "F");
            return(View(loTutorial));
        }
Esempio n. 7
0
 public ActionResult Edit(TutorialsModel tutorialsModel)
 {
     if (ModelState.IsValid)
     {
         tutorialsModel.UpdateAt = DateTime.Now;
         Tutorials tutorials = tutorialsModel.ToEntity();
         tutorialsCRUD.Update(tutorials);
         return(RedirectToAction("Index"));
     }
     return(View(tutorialsModel));
 }
Esempio n. 8
0
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tutorials      tutorials      = tutorialsCRUD.GetTutorialsById(id);
            TutorialsModel tutorialsModel = tutorials.ToModel();

            return(View(tutorialsModel));
        }
Esempio n. 9
0
 public ActionResult Create(TutorialsModel tutorialsModel)
 {
     if (ModelState.IsValid)
     {
         tutorialsModel.TutorialsID = Guid.NewGuid().ToString();
         tutorialsModel.CreateAt    = DateTime.Now;
         tutorialsModel.UpdateAt    = DateTime.Now;
         string userID = HttpContext.Session["UserID"] as string;
         tutorialsModel.UserID = userID;
         Tutorials tutorials = tutorialsModel.ToEntity();
         tutorialsCRUD.Create(tutorials);
         return(RedirectToAction("Index"));
     }
     return(View(tutorialsModel));
 }
Esempio n. 10
0
        public ActionResult NotesUpload(TutorialsModel FormData)
        {
            HttpPostedFileBase DP = FormData.Doc;

            if (DP != null && (DP.ContentLength <= 10240000 && DP.ContentType == "application/docx" || DP.ContentType == "application/pdf" || DP.ContentType == "text/plain"))
            {
                TutorialsDataContext UploadContext = new TutorialsDataContext();
                var path = Request.PhysicalApplicationPath;
                if (!Directory.Exists(path + "Uploads"))
                {
                    Directory.CreateDirectory(path + "Uploads");
                }
                DP.SaveAs(path + "Uploads/" + DP.FileName);
                UploadContext.Upload(Session["UserID"], DP.FileName, path, FormData.Subject, FormData.Category, FormData.Description);
                ViewBag.msg     = path;
                ViewData["msg"] = path;
            }
            else
            {
                ViewBag.msg     = "Error occured";
                ViewData["msg"] = "Error Occured";
            }
            return(RedirectToAction("Index", "Tutorials", new { area = "Admin" }));
        }
Esempio n. 11
0
 public static Tutorials ToEntity(this TutorialsModel model)
 {
     return(model.MapTo <TutorialsModel, Tutorials>());
 }
Esempio n. 12
0
        public ActionResult Create()
        {
            TutorialsModel tutorialsModel = new TutorialsModel();

            return(View(tutorialsModel));
        }