Ejemplo 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"));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        public List <TutorialsModel> GetTutorialsBySearch(string Subject, string Category, string Keywords)
        {
            List <SqlParameter>  ProcParam = new List <SqlParameter>();
            TutorialsDataContext sqldb     = new TutorialsDataContext();

            ProcParam.Add(new SqlParameter("Subject", Subject.handleDBNull()));
            ProcParam.Add(new SqlParameter("Category", Category.handleDBNull()));
            ProcParam.Add(new SqlParameter("Keywords", Keywords.handleDBNull()));
            return(new AdminDataContext().Database.SqlQuery <TutorialsModel>("GetTutorialsBySearch".getSql(ProcParam), ProcParam.ToArray()).ToList());
        }
Ejemplo n.º 4
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" }));
        }