コード例 #1
0
        public ActionResult UploadDocuments()
        {
            Session["lang"] = WebConfigurationManager.AppSettings["DefaultLang"];
            if (Session["UserInfo"] == null || Session["RequestId"] == null)
            {
                return(RedirectToRoute("Default", new { lang = Session["lang"], controller = "Account", action = "Index" }));
            }

            var req = requestSVC.FindById(decimal.Parse(Session["RequestId"].ToString()));

            ViewBag.St_Request   = req;
            ViewBag.St_LastLevel = req.Student?.EducationDegrees?.OrderByDescending(ord => ord.Level).FirstOrDefault();


            //var accountId = 5;//(Session["UserInfo"] as Models.UserViewModel).Id;
            TempData["studentID"] = req.StudentId; //accountSVC.FindById(accountId).StudentId;

            //var countries = new SelectList(countrySVC.FetchAll().OrderBy(o => o.Name), "Id", "DisplayName").ToList();
            //countries.Insert(0, new SelectListItem { Text = Resources.Dropdown_Choose, Value = "0" });
            //ViewBag.CountryList = countries;

            //var fields = new SelectList(fieldsSVC.FetchAll().OrderBy(o => o.Field_Name), "Id", "Field_Name").ToList();
            //fields.Insert(0, new SelectListItem { Text = Resources.Dropdown_Choose, Value = "0" });
            //ViewBag.AllFields = fields;

            var docs = studentDocSVC.FetchMany(doc => doc.SudentId == req.StudentId).ToList();

            var docPersonalPicture = docs.FirstOrDefault(doc => doc.FileName.Contains(DocumentsMangement.PersonalPicture));

            ViewBag.vbPersonalPicture = docPersonalPicture == null ? "#" : docPersonalPicture.Path + "/" + docPersonalPicture.FileName + "?ts=" + Helpers.TimeStamp();


            var docPassport = docs.FirstOrDefault(doc => doc.FileName.Contains(DocumentsMangement.Passport));

            ViewBag.vbPassport = docPassport == null ? "#" : docPassport.Path + "/" + docPassport.FileName + "?ts=" + Helpers.TimeStamp();

            var docDiploma = docs.FirstOrDefault(doc => doc.FileName.Contains(DocumentsMangement.Diploma));

            ViewBag.vbDiploma = docDiploma == null ? "#" : docDiploma.Path + "/" + docDiploma.FileName + "?ts=" + Helpers.TimeStamp();

            var docCollage = docs.FirstOrDefault(doc => doc.FileName.Contains(DocumentsMangement.Collage));

            ViewBag.vbCollage = docCollage == null ? "#" : docCollage.Path + "/" + docCollage.FileName + "?ts=" + Helpers.TimeStamp();

            var docBachelor = docs.FirstOrDefault(doc => doc.FileName.Contains(DocumentsMangement.Bachelor));

            ViewBag.vbBachelor = docBachelor == null ? "#" : docBachelor.Path + "/" + docBachelor.FileName + "?ts=" + Helpers.TimeStamp();

            var docMaster = docs.FirstOrDefault(doc => doc.FileName.Contains(DocumentsMangement.Master));

            ViewBag.vbMaster = docMaster == null ? "#" : docMaster.Path + "/" + docMaster.FileName + "?ts=" + Helpers.TimeStamp();

            var docPhd = docs.FirstOrDefault(doc => doc.FileName.Contains(DocumentsMangement.Phd));

            ViewBag.vbPhd = docPhd == null ? "#" : docPhd.Path + "/" + docPhd.FileName + "?ts=" + Helpers.TimeStamp();


            return(View());
        }
        public ActionResult GetRequestInfo(int id = 0, string term = null)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture   = new System.Globalization.CultureInfo("en-GB");
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fa-IR");

            var reqVM = new RequestViewModel();

            if (id > 0)
            {
                var req = _requestService.FindById(id);

                if (req != null)
                {
                    CitizenShipViewModel     citizenShipsVM    = null;
                    CountryViewModel         countryVM         = null;
                    AddressViewModel         addressVM         = null;
                    CandidateFieldViewModel  candidateFieldsVM = null;
                    FieldForForeignViewModel fieldForForeignVM = null;
                    EducationDegreeViewModel educationDegreeVM = null;
                    RequestDocViewModel      documentVM        = null;

                    var studentVM              = new StudentViewModel();
                    var personVM               = new PersonViewModel();
                    var citizenShipsListVM     = new List <CitizenShipViewModel>();
                    var countryListVM          = new CountryViewModel();
                    var addressListVM          = new List <AddressViewModel>();
                    var candidateFieldsListVM  = new List <CandidateFieldViewModel>();
                    var fieldForForeignListVM  = new List <FieldForForeignViewModel>();
                    var educationDegreesListVM = new List <EducationDegreeViewModel>();
                    var documentsListVM        = new List <RequestDocViewModel>();


                    var recommender     = req.Student.Person.RelatedPersons?.FirstOrDefault(w => w.MainPersonRelationType == (byte)RelationType.Recommender);
                    var recommenderCode = recommender != null
                        ? _personService.FindById(recommender.RelatedPersonId).RecommenderCode ?? "--"
                        : "--";

                    reqVM.CreateDate  = (DateTime)req.CreateDate;
                    reqVM.Id          = req.Id;
                    reqVM.Status      = Convert.ToByte(req.Status);
                    reqVM.StatusName  = Resources.Resources.ResourceManager.GetString(((RequestStatus)req.Status).ToString());
                    reqVM.TargetLevel = Resources.Resources.ResourceManager.GetString((req.CurrentLevel == null ? Levels.UnKnown : (Levels)req.CurrentLevel).ToString());
                    reqVM.Discription = req.Status == (byte)RequestStatus.M_Enrollment_Rejected ? (!string.IsNullOrEmpty(req.Description) ? req.Description : "") : "";

                    //alert_danger_show is a class in requestReview view
                    reqVM.AlertMessage = req.Status == (byte)RequestStatus.M_Enrollment_Rejected ? (!string.IsNullOrEmpty(req.Description) ? "alert_danger_show" : "") : "";

                    var studentObject = _studentService.FindOne(x => x.Id == req.StudentId);
                    if (studentObject != null)
                    {
                        studentVM.ChildrenCount     = studentObject.ChildrenCount ?? 0;
                        studentVM.Email             = studentObject?.Email ?? "";
                        studentVM.HealthStatusTitle = studentObject.HealthStatus != null?Resources.Resources.ResourceManager.GetString(((HealthStatus)studentObject.HealthStatus).ToString()) : Resources.Resources.ResourceManager.GetString((HealthStatus.CompleteHealth).ToString());

                        studentVM.Mobile        = studentObject?.Mobile ?? "";
                        studentVM.ReligienTitle = Resources.Resources.ResourceManager.GetString(((Religion)studentObject.Religien).ToString());
                        studentVM.HealthStatus  = studentObject.HealthStatus;

                        var personObject = _personService.FindOne(x => x.Id == studentObject.PersonId);
                        if (personObject != null)
                        {
                            personVM.FirstName         = personObject.FirstName;
                            personVM.LastName          = personObject.LastName;
                            personVM.MiddleName        = personObject?.MiddleName ?? "";
                            personVM.FathersName       = personObject?.FatherName ?? "";
                            personVM.MothersName       = personObject?.MotherName ?? "";
                            personVM.GrandFathersName  = personObject?.GrandFatherName ?? "";
                            personVM.BirthDate         = personObject.BirthDate.Value.ToString("yyyy/MM/dd");
                            personVM.BirthPlace        = personObject.BirthPlace;
                            personVM.Gender            = personObject.Gender;
                            personVM.GenderTitle       = Resources.Resources.ResourceManager.GetString(((Gender)personObject.Gender).ToString());
                            personVM.MarritalType      = personObject.MarritalType;
                            personVM.MarritalTypeTitle = Resources.Resources.ResourceManager.GetString(((MarritalStatus)personObject.MarritalType).ToString());
                            personVM.RecommenderCode   = recommenderCode;

                            var citizenshipsObject = _citizenShipService.FetchMany(x => x.PersonId == personObject.Id);
                            if (citizenshipsObject != null && citizenshipsObject.Count() > 0)
                            {
                                foreach (var citizen in citizenshipsObject)
                                {
                                    citizenShipsVM = new CitizenShipViewModel();
                                    //---------------------------
                                    citizenShipsVM.Active     = citizen.Active;
                                    citizenShipsVM.PersonId   = citizen.PersonId;
                                    citizenShipsVM.IssuePlace = citizen.IssuePlace;
                                    citizenShipsVM.IssueDate  = citizen.IssueDate;
                                    citizenShipsVM.Id         = citizen.Id;
                                    citizenShipsVM.DocType    = string.IsNullOrEmpty(citizen.DocType.ToString()) ? 0 : citizen.DocType;
                                    citizenShipsVM.DocNo      = citizen.DocNo;
                                    citizenShipsVM.CountryId  = citizen.CountryId;
                                    //---------------------------
                                    if (!string.IsNullOrEmpty(citizen.CountryId?.ToString()))
                                    {
                                        var countryObject = _countryService.FetchMany(x => x.Id == citizen.CountryId).FirstOrDefault();
                                        if (countryObject != null)
                                        {
                                            countryVM = new CountryViewModel();

                                            countryVM.Active       = countryObject.Active;
                                            countryVM.CountryCode  = countryObject.CountryCode;
                                            countryVM.DisplayName  = countryObject.DisplayName;
                                            countryVM.Id           = countryObject.Id;
                                            countryVM.LanguageCode = countryObject.LanguageCode;
                                            countryVM.Name         = countryObject.Name;
                                            countryVM.PhoneCode    = countryObject.PhoneCode;
                                            //---------------------------
                                            citizenShipsVM.Country = countryVM;
                                        }
                                    }
                                    //---------------------------
                                    citizenShipsListVM.Add(citizenShipsVM);
                                }
                                personVM.CitizenShips = citizenShipsListVM;
                            }

                            var addressListObject = _addressService.FetchMany(x => x.PersonId == personObject.Id);
                            if (addressListObject != null && addressListObject.Count() > 0)
                            {
                                foreach (var address in addressListObject)
                                {
                                    addressVM = new AddressViewModel();

                                    addressVM.Active            = address.Active;
                                    addressVM.AddressType       = address.AddressType;
                                    addressVM.City              = address.City;
                                    addressVM.Mobile2           = address.Mobile;
                                    addressVM.Email2            = address.Email;
                                    addressVM.Id                = address.Id;
                                    addressVM.PersonId          = address.PersonId;
                                    addressVM.PhoneNo           = address.PhoneNo;
                                    addressVM.PostalCode        = address.PostalCode;
                                    addressVM.Plaque            = address.Plaque;
                                    addressVM.PreCodeForMobile  = address.PreCodeForMobile;
                                    addressVM.PreCodeForPhoneNo = address.PreCodeForPhoneNo;
                                    addressVM.Province          = address.Province;
                                    addressVM.Street            = address.Street;

                                    addressListVM.Add(addressVM);
                                }
                                personVM.Addresses = addressListVM;
                            }
                            studentVM.Person = personVM;
                        }

                        var candidateFieldsObject = _condidateService.FetchMany(x => x.StudentId == studentObject.Id);
                        if (candidateFieldsObject != null && candidateFieldsObject.Count() > 0)
                        {
                            foreach (var candidateField in candidateFieldsObject)
                            {
                                candidateFieldsVM = new CandidateFieldViewModel();

                                candidateFieldsVM.Active    = candidateField.Active;
                                candidateFieldsVM.Selected  = candidateField.Selected;
                                candidateFieldsVM.Id        = candidateField.Id;
                                candidateFieldsVM.StudentId = candidateField.StudentId;

                                //---------------------------
                                fieldForForeignVM = new FieldForForeignViewModel();
                                //---------------------------
                                fieldForForeignVM.Code_Baygan  = candidateField.FieldForForeign.Code_Baygan;
                                fieldForForeignVM.Field_Name   = candidateField.FieldForForeign.Field_Name;
                                fieldForForeignVM.Id           = candidateField.FieldForForeign.Id;
                                fieldForForeignVM.LanguageCode = candidateField.FieldForForeign.LanguageCode;
                                fieldForForeignVM.Sida_ID      = candidateField.FieldForForeign.Sida_ID;
                                fieldForForeignVM.CollegeId    = candidateField.FieldForForeign.CollegeId;

                                //---------------------------
                                candidateFieldsVM.FieldForForeign = fieldForForeignVM;

                                candidateFieldsListVM.Add(candidateFieldsVM);
                            }

                            candidateFieldsListVM.OrderByDescending(o => o.Selected);
                            studentVM.CandidateFields = candidateFieldsListVM;

                            //---------------------------
                            //foreach (var field in candidateFieldsListVM.Select(s => s.FieldForForeign))
                            //{
                            //    if (field.CollegeId != null && field.CollegeId > 0)
                            //    {
                            //        var col = _collegeService.FindById(field.CollegeId);
                            //        if (col != null)
                            //            field.College = new CollegeViewModel
                            //            {
                            //                Active = col.Active,
                            //                CollegeName = col.CollegeName,
                            //                LanguageCode = col.LanguageCode,
                            //                Id = col.Id,
                            //                SIDA_Code = col.SIDA_Code
                            //            };
                            //    }
                            //}
                        }

                        var educationDegreesObject = _educationDegreeService.FetchMany(x => x.SudentId == studentObject.Id);

                        if (educationDegreesObject != null && educationDegreesObject.Count() > 0)
                        {
                            foreach (var degree in educationDegreesObject)
                            {
                                educationDegreeVM = new EducationDegreeViewModel();

                                educationDegreeVM.Active               = degree.Active;
                                educationDegreeVM.CountryName          = degree.CountryName;
                                educationDegreeVM.EducationDegreePlace = degree.EducationDegreePlace;
                                educationDegreeVM.EndTimeInLevel       = degree.EndTimeInLevel;
                                educationDegreeVM.FieldId              = degree.FieldId;
                                educationDegreeVM.FieldTitle           = degree.FieldTitle;
                                educationDegreeVM.Id             = degree.Id;
                                educationDegreeVM.Level          = degree.Level;
                                educationDegreeVM.LevelTitle     = Resources.Resources.ResourceManager.GetString(((Levels)degree.Level).ToString());
                                educationDegreeVM.TotalAverage   = degree.TotalAverage;
                                educationDegreeVM.UniversityName = degree.UniversityName;
                                educationDegreeVM.WrittenAverage = degree.WrittenAverage;

                                educationDegreesListVM.Add(educationDegreeVM);
                            }
                            studentVM.EducationDegrees = educationDegreesListVM;
                        }


                        var studentDocumentsObject = _studentDocService.FetchMany(x => x.SudentId == studentObject.Id && req.Term == x.Term);

                        if (studentDocumentsObject != null && studentDocumentsObject.Count() > 0)
                        {
                            foreach (var document in studentDocumentsObject)
                            {
                                documentVM = new RequestDocViewModel();

                                documentVM.Category       = document.Category;
                                documentVM.CategoryTitle  = Resources.Resources.ResourceManager.GetString(((DocType)document.Category).ToString());
                                documentVM.DocStatus      = document.DocStatus;
                                documentVM.DocStatusTitle = Resources.Resources.ResourceManager.GetString(((DocStatus)document.DocStatus).ToString());
                                documentVM.FileName       = document.FileName;
                                documentVM.Id             = document.Id;
                                documentVM.Path           = document.Path;
                                documentVM.StudentId      = document.Student.Id;
                                documentVM.Term           = document.Term;

                                documentsListVM.Add(documentVM);
                            }
                        }

                        reqVM.Student   = studentVM;
                        reqVM.Documents = documentsListVM;
                    }
                }
            }
            return(PartialView("_InternationalManager", reqVM));
        }