Exemplo n.º 1
0
        protected List <EducationDegreeViewModel> CreateDegreesModel(string professionId)
        {
            //TODO: degrees should be taken for profession
            var degrees = new List <EducationDegreeViewModel>();
            var school  = new EducationDegreeViewModel()
            {
                IsReached = true, MinReachAge = 14, ReachedIn = 14, Title = "Школа", IncomePercent = 0
            };
            var bachelorDegree = new EducationDegreeViewModel()
            {
                IsReached = false, MinReachAge = 18, ReachedIn = 18, Title = "Бакалавр", IncomePercent = 0.10m
            };
            var masterDegree = new EducationDegreeViewModel()
            {
                IsReached = false, MinReachAge = 20, ReachedIn = 20, Title = "Магістр", IncomePercent = 0.15m
            };
            var doctoralDegree = new EducationDegreeViewModel()
            {
                IsReached = false, MinReachAge = 25, ReachedIn = 25, Title = "Докторська", IncomePercent = 0.20m
            };

            degrees.Add(school);
            degrees.Add(bachelorDegree);
            degrees.Add(masterDegree);
            if (professionId == "1")
            {
                degrees.Add(doctoralDegree);
            }

            return(degrees);
        }
        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));
        }