private StudentDoc SetDocumentModelByParams(decimal studentId, string fileName, byte catagory, byte docStaus, string term, bool active)
        {
            var setDoc = new StudentDoc();
            var path   = $"../../../{basePath}/{term}/{studentId}";

            setDoc.SudentId  = studentId;
            setDoc.FileName  = fileName;
            setDoc.Path      = path;
            setDoc.Category  = catagory;
            setDoc.DocStatus = docStaus;
            setDoc.Term      = term;
            setDoc.Active    = active;
            return(setDoc);
        }
        public ActionResult Student(StudentDoc studentDoc)
        {
            if (studentDoc.DTId > 0 && !(String.IsNullOrEmpty(studentDoc.DocDesc)) && studentDoc.SDoc != null && studentDoc.SDoc.ContentLength > 0)
            {
                studentDoc.DocSId = Convert.ToInt32(Session["SId"].ToString());
                try
                {
                    string    StudentFilename = ((DateTime.Now.ToString("dd_MM_yyyy_HH:mm")).Replace(":", "") + studentDoc.SDoc.FileName);
                    Documents documents       = new Documents();
                    documents.DTId  = studentDoc.DTId;
                    documents.DDesc = studentDoc.DocDesc;
                    documents.DName = StudentFilename;
                    documents.DURL  = StudentFilename;
                    documents.TId   = studentDoc.TId;
                    documents.SId   = studentDoc.DocSId;
                    documents.DSId  = 1;
                    StudentIntern.Documents.Add(documents);
                    StudentIntern.SaveChanges();
                    string Upath = Path.Combine(HttpContext.Server.MapPath("~/Content/Documents"), Path.GetFileName(StudentFilename));
                    studentDoc.SDoc.SaveAs(Upath);

                    ViewBag.company  = "";
                    ViewBag.Success += "Staj Dosyaniz Başarıyla Eklenmiştir.";

                    ViewBag.Title   = new SelectList(StudentIntern.DocTitle, "DTId", "DTAck");
                    ViewBag.Teacher = new SelectList(StudentIntern.Teacher, "TId", "TAdSoyad");
                }
                catch (Exception)
                {
                    throw;
                }
            }
            else
            {
                ViewBag.Success = "";
            }

            ViewBag.Title   = new SelectList(StudentIntern.DocTitle, "DTId", "DTAck");
            ViewBag.Teacher = new SelectList(StudentIntern.Teacher, "TId", "TAdSoyad");


            return(View());
        }
        //public ActionResult UploadDocuments(HttpPostedFileBase Passport_f, HttpPostedFileBase Diploma_f, HttpPostedFileBase Collage_f, HttpPostedFileBase Bachelor_f, HttpPostedFileBase Master_f, HttpPostedFileBase Phd_f, string txt_LastEducationDegree = "0", string txt_AllFields = "0", string txt_LastEducationAverage = "0", string txt_LastEducationDate = "0", string txt_CountryList = "0", string txt_CurentLevel = "0", string txt_Candidate_Fields = "0")
        public ActionResult UploadDocuments(HttpPostedFileBase PersonalPicture_f, HttpPostedFileBase Passport_f, HttpPostedFileBase Diploma_f, HttpPostedFileBase Collage_f, HttpPostedFileBase Bachelor_f, HttpPostedFileBase Master_f, HttpPostedFileBase Phd_f, string txt_LastEducationDegree = "0", string txt_CurentLevel = "0")
        {
            var validation = formDataIsValid(PersonalPicture_f, Passport_f, Diploma_f, Collage_f, Bachelor_f, Master_f, Phd_f, txt_LastEducationDegree, txt_CurentLevel);

            if (!validation)
            {
                //return View("UploadDocuments");
                return(RedirectToAction("UploadDocuments"));
            }
            var studentID = (TempData["studentID"] as decimal?);

            if (studentID.HasValue)
            {
                StudentDoc doc  = null;
                var        path = $"~/{basePath}/{term}/{studentID.Value}";

                if (PersonalPicture_f != null)
                {
                    //save image on server
                    var res = DocumentsMangement.SaveInputStreamAsImage(PersonalPicture_f, path, DocumentsMangement.PersonalPicture);
                    if (res)
                    {
                        var fileName = $"PersonalPicture.{PersonalPicture_f.FileName.Split('.')[1].ToLower()}";
                        doc = this.SetDocumentModelByParams(studentID.Value, fileName, (byte)DocType.PersonalPicture, docStatus, term, active);
                        //save doc info in database
                        var x = studentDocSVC.AddNewItem(doc);
                    }
                }


                if (Passport_f != null)
                {
                    //save image on server
                    var res = DocumentsMangement.SaveInputStreamAsImage(Passport_f, path, DocumentsMangement.Passport);
                    if (res)
                    {
                        var fileName = $"Passport.{Passport_f.FileName.Split('.')[1].ToLower()}";
                        doc = this.SetDocumentModelByParams(studentID.Value, fileName, (byte)DocType.Passport, docStatus, term, active);
                        //save doc info in database
                        var x = studentDocSVC.AddNewItem(doc);
                    }
                }

                if (Diploma_f != null)
                {
                    var res = DocumentsMangement.SaveInputStreamAsImage(Diploma_f, path, DocumentsMangement.Diploma);
                    if (res)
                    {
                        var fileName = $"Diploma.{Diploma_f.FileName.Split('.')[1].ToLower()}";
                        doc = this.SetDocumentModelByParams(studentID.Value, fileName, (byte)DocType.Diploma, docStatus, term, active);
                        //save doc info in database
                        var x = studentDocSVC.AddNewItem(doc);
                    }
                }

                if (Collage_f != null)
                {
                    var res = DocumentsMangement.SaveInputStreamAsImage(Collage_f, path, DocumentsMangement.Collage);
                    if (res)
                    {
                        var fileName = $"Collage.{Collage_f.FileName.Split('.')[1].ToLower()}";
                        doc = this.SetDocumentModelByParams(studentID.Value, fileName, (byte)DocType.Collage, docStatus, term, active);
                        //save doc info in database
                        var x = studentDocSVC.AddNewItem(doc);
                    }
                }

                if (Bachelor_f != null)
                {
                    var res = DocumentsMangement.SaveInputStreamAsImage(Bachelor_f, path, DocumentsMangement.Bachelor);
                    if (res)
                    {
                        var fileName = $"Bachelor.{Bachelor_f.FileName.Split('.')[1].ToLower()}";
                        doc = this.SetDocumentModelByParams(studentID.Value, fileName, (byte)DocType.Bachelor, docStatus, term, active);
                        //save doc info in database
                        var x = studentDocSVC.AddNewItem(doc);
                    }
                }

                if (Master_f != null)
                {
                    var res = DocumentsMangement.SaveInputStreamAsImage(Master_f, path, DocumentsMangement.Master);
                    if (res)
                    {
                        var fileName = $"Master.{Master_f.FileName.Split('.')[1].ToLower()}";
                        doc = this.SetDocumentModelByParams(studentID.Value, fileName, (byte)DocType.Master, docStatus, term, active);
                        //save doc info in database
                        var x = studentDocSVC.AddNewItem(doc);
                    }
                }

                if (Phd_f != null)
                {
                    var res = DocumentsMangement.SaveInputStreamAsImage(Phd_f, path, DocumentsMangement.Phd);
                    if (res)
                    {
                        var fileName = $"Phd.{Phd_f.FileName.Split('.')[1].ToLower()}";
                        doc = this.SetDocumentModelByParams(studentID.Value, fileName, (byte)DocType.Phd, docStatus, term, active);
                        //save doc info in database
                        var x = studentDocSVC.AddNewItem(doc);
                    }
                }
            }
            UpdateDocStatus_InRequestTable(txt_CurentLevel, txt_LastEducationDegree);
            return(RedirectToAction("Index", "Request"));
            //return View("UploadDocuments");
        }