//public JsonResult ReUploadDocument(FormCollection formCollection)
        public JsonResult ReUploadDocument()
        {
            var form         = HttpContext.Request.Form;
            var hdn_reqid    = form["hdn_reqid"];
            var hdn_doc_id   = form["hdn_doc_id"];
            var hdn_detector = form["hdn_detector"];
            //var reqId = decimal.Parse(string.IsNullOrEmpty(formCollection["hdn_reqid"]) ? "-1" : formCollection["hdn_reqid"]);
            //var docId = decimal.Parse(string.IsNullOrEmpty(formCollection["hdn_doc_id"]) ? "-1" : formCollection["hdn_doc_id"]);
            //var checker = string.IsNullOrEmpty(formCollection["hdn_detector"]) ? "-1" : formCollection["hdn_detector"];

            var        reqId   = decimal.Parse(string.IsNullOrEmpty(hdn_reqid) ? "-1" : hdn_reqid);
            var        docId   = decimal.Parse(string.IsNullOrEmpty(hdn_doc_id) ? "-1" : hdn_doc_id);
            var        checker = string.IsNullOrEmpty(hdn_detector) ? "-1" : hdn_detector;
            JsonResult res;

            if (docId != -1 && reqId != -1 && checker != "-1")
            {
                var docItem = studentDocSVC.FindById(docId);
                if (docItem != null)
                {
                    var path        = $"~/{basePath}/{term}/{docItem.Student.Id}";
                    var PostedFiles = Request.Files;
                    if (PostedFiles.Count > 0)
                    {
                        var docName = GetDocName((byte)docItem.Category);
                        if (docName != "")
                        {
                            var x = DocumentsMangement.SaveInputStreamAsImage(PostedFiles[0], path, docName);
                            if (x)
                            {
                                var fileName = $"{docName}.{PostedFiles[0].FileName.Split('.')[1].ToLower()}";

                                docItem.FileName    = fileName;
                                docItem.DocStatus   = checker == "k" ? Karshenas_UpdateDocStatus : docStatus;
                                docItem.Path        = path.Replace("~/", "../../../");
                                docItem.Description = "";

                                var xx = studentDocSVC.UpdatetItem(docItem);
                                res = new JsonResult {
                                    Data = new { Result = true, Messege = Request.Files.Count }
                                };
                                return(res);
                            }
                        }
                    }
                }
            }
            res = new JsonResult {
                Data = new { Result = false, Messege = "Invalid request !!!" }
            };
            return(res);

            /*
             * for (int i = 0; i < Request.Files.Count; i++)
             * {
             *  HttpPostedFileBase file = Request.Files[i]; //Uploaded file
             *  //Use the following properties to get file's name, size and MIMEType
             *  int fileSize = file.ContentLength;
             *  string fileName = file.FileName;
             *  string mimeType = file.ContentType;
             *  System.IO.Stream fileContent = file.InputStream;
             *  //To save file, use SaveAs method
             *  var path = "~/st_documents/97-98-2/22/";
             *  file.SaveAs(Server.MapPath(path) + fileName); //File will be saved in application root
             * }
             * var res = new JsonResult { Data = new { Result = true, Messege = Request.Files.Count } };
             * return res;
             */
        }
        //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");
        }