public ActionResult UploadFile(DisciplineUploadFileModel discipline)
        {
            for (int i = 0; i < Request.Files.Count; i++)
            {
                HttpPostedFileBase arquivo = Request.Files[i];

                if (arquivo.ContentLength > 0)
                {
                    if (arquivo.ContentType.Equals("application/pdf"))
                    {
                        string fileName = discipline.CodeDiscipline + ".pdf";
                        UploadFileUtil.FTPUpload(fileName, arquivo);
                    }
                }
            }
            if (discipline.CourseOptionRoute != null)
            {
                string action = CourseController.GetRoute((int)discipline.CourseOptionRoute);

                if (discipline.CourseOptionRoute != (int)CourseOptionRouteEnum.INDIVIDUAL)
                {
                    return(RedirectToAction(action, "Course").Success("Arquivo enviado com sucesso"));
                }
                return(RedirectToAction(action, "Course", new { code = discipline.CodeCourse }).Success("Arquivo enviado com sucesso"));
            }
            else if (discipline.CodeTeacher != null)
            {
                return(RedirectToAction("AllTeachers", "Teacher").Success("Arquivo enviado com sucesso"));
            }
            else
            {
                return(RedirectToAction("AllDisciplines", "Discipline").Success("Arquivo enviado com sucesso"));
            }
        }
Beispiel #2
0
        public ActionResult UploadFile(CourseUploadFileModel course)
        {
            for (int i = 0; i < Request.Files.Count; i++)
            {
                HttpPostedFileBase file = Request.Files[i];

                if (file.ContentLength > 0)
                {
                    if (file.ContentType.Equals("application/pdf"))
                    {
                        var    type     = Request.Files.Keys[i];
                        string fileName = GetFileName(type);
                        fileName = fileName + "_" + course.CodeCourse + ".pdf";
                        UploadFileUtil.FTPUpload(fileName, file);
                    }
                }
            }

            string action = GetRoute(course.OptionRoute);

            if (course.OptionRoute != (int)CourseOptionRouteEnum.INDIVIDUAL)
            {
                return(RedirectToAction(action, "Course"));
            }
            return(RedirectToAction(action, "Course", new { code = course.CodeCourse }).Success("Arquivo enviado com sucesso"));
        }
        public ActionResult UploadFile(InstitutionalUploadFileModel model)
        {
            for (int i = 0; i < Request.Files.Count; i++)
            {
                HttpPostedFileBase arquivo = Request.Files[i];

                if (arquivo.ContentLength > 0)
                {
                    if (arquivo.ContentType.Equals("application/pdf"))
                    {
                        string fileName = SetFileName(model.IdType) + ".pdf";
                        UploadFileUtil.FTPUpload(fileName, arquivo);
                    }
                }
            }
            return(RedirectToAction("AllCourses", "Course").Success("Arquivo enviado com sucesso"));
        }