public bool CreatePilotAdmission(ptaPilotRegistrationMaster Model, int CreatedBy) { bool status = false; ptaAdmissionMaster admission = new ptaAdmissionMaster { Fname = Model.Fname, Lanme = Model.Lname, Email = Model.Email, Mobile = Model.Mobile, DOB = Model.DOB, Height = Model.Height, CourseId = Model.CourseId, SessionId = Model.SessionId, ApplicationNo = Model.ApplicationNo, AdmissionBy = CreatedBy, AdmissionDate = DateTime.Now, IsActive = true }; _context.ptaAdmissionMasters.Add(admission); var data = _context.ptaRegistrationInfoes.Where(p => p.ptaPilotRegistrationMasterId == Model.Id).FirstOrDefault(); if (data != null) { data.AdmissionId = admission.Id; } _context.SaveChanges(); status = true; return(status); }
public PilotRegistrationViewModel CreatePilotTrainingRegistration(PilotRegistrationViewModel model) { ptaPilotRegistrationMaster register = new ptaPilotRegistrationMaster(); if (!string.IsNullOrEmpty(model.CourseApplied)) { var courseInfo = _context.CourseMasters.Where(c => c.IsActive && c.DepartmentMasterId == 2 && c.CourseName == model.CourseApplied).FirstOrDefault(); if (courseInfo != null) { int PilotSessionId = GetPilotSessionIdByCourse(courseInfo.Id, DateTime.Now.Year, courseInfo.CourseName); register.CourseId = courseInfo.Id; register.SessionId = PilotSessionId; } } register.Fname = model.FirstName; register.Lname = model.Lastname; register.Email = model.Email; register.Mobile = model.MobileNo; if (model.DateOfBirth != null && model.DateOfBirth != "") { register.DOB = DateTime.ParseExact(model.DateOfBirth, "dd/MM/yyyy", CultureInfo.InvariantCulture); } register.Height = model.Height; register.DepartmentMasterId = 2; register.RegistrationDate = DateTime.Now; register.RegistrationNo = PilotMaxRegistartionNumber(); register.IsActive = true; register.ApplicationNo = model.ApplicationNo; _context.ptaPilotRegistrationMasters.Add(register); ptaRegistrationInfo PilotRegister = new ptaRegistrationInfo(); PilotRegister.ptaPilotRegistrationMasterId = register.Id; PilotRegister.RegistartionNo = "PTA" + register.RegistrationNo; if (!string.IsNullOrEmpty(model.Title)) { PilotRegister.ptaTitleMasterId = Convert.ToInt32((Title)Enum.Parse(typeof(Title), model.Title)); } if (!string.IsNullOrEmpty(model.Gender)) { PilotRegister.ptaGenderMasterId = Convert.ToInt32((Gender)Enum.Parse(typeof(Gender), model.Gender.Replace(" ", string.Empty))); } if (!string.IsNullOrEmpty(model.Nationality)) { if (model.Nationality == "Overseas Citizen of India (OCI)") { PilotRegister.ptaNatioalityMasterId = 2; } else { PilotRegister.ptaNatioalityMasterId = Convert.ToInt32((Nationality)Enum.Parse(typeof(Nationality), model.Nationality.Replace(" ", string.Empty))); } } if (!string.IsNullOrEmpty(model.LeadSource)) { PilotRegister.ptaLeadSourceMasterId = Convert.ToInt32((LeadSource)Enum.Parse(typeof(LeadSource), model.LeadSource)); } if (!string.IsNullOrEmpty(model.MedicalStatus)) { PilotRegister.ptaMedicalStatusMasterId = Convert.ToInt32((MedicalStatus)Enum.Parse(typeof(MedicalStatus), model.MedicalStatus.Replace(" ", string.Empty))); } _context.ptaRegistrationInfoes.Add(PilotRegister); if (!string.IsNullOrEmpty(model.PassportNo)) { ptaPassport passport = new ptaPassport(); passport.PassportCountry = model.PassportCountry; passport.PassportNo = model.PassportNo; passport.PlaceOfIssue = model.PassportPlaceOfIssue; if (!string.IsNullOrEmpty(model.PassportDateOfExpiry)) { passport.DateOfExpiry = DateTime.ParseExact(model.PassportDateOfExpiry, "dd/MM/yyyy", CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(model.PassportDateOfIssue)) { passport.DateOfIssue = DateTime.ParseExact(model.PassportDateOfIssue, "dd/MM/yyyy", CultureInfo.InvariantCulture); } passport.ptaRegistrationInfoId = PilotRegister.Id; _context.ptaPassports.Add(passport); } if (!string.IsNullOrEmpty(model.GuardianName)) { ptaGuardian Guardian = new ptaGuardian(); Guardian.Name = model.GuardianName; Guardian.Mobile = model.GuardianMobNo; Guardian.Relation = model.GuardianRelation; Guardian.ptaRegistrationInfoId = PilotRegister.Id; _context.ptaGuardians.Add(Guardian); } if (!string.IsNullOrEmpty(model.CorrespondenceCountry)) { ptaAddressDetail Address = new ptaAddressDetail(); Address.Cor_Country = model.CorrespondenceCountry; Address.Cor_State = model.CorrespondenceState; Address.Cor_District = model.CorrespondenceDistrict; Address.Cor_City = model.CorrespondenceCity; Address.Cor_Address1 = model.CorrespondenceAddress1; Address.Cor_Address2 = model.CorrespondenceAddress2; Address.Cor_PinCode = model.CorrespondencePinCode; Address.IsPermanent = model.SameAsCorrespondance; if (!string.IsNullOrEmpty(model.PermanentCountry)) { Address.Per_Country = model.PermanentCountry; Address.Per_State = model.PermanentState; Address.Per_District = model.PermanentDistrict; Address.Per_City = model.PermanentCity; Address.Per_Address1 = model.PermanentAddress1; Address.Per_Address2 = model.PermanentAddress2; Address.Per_PinCode = model.PermanentPinCode; } Address.ptaRegistrationInfoId = PilotRegister.Id; _context.ptaAddressDetails.Add(Address); } if (!string.IsNullOrEmpty(model.ApplicantName)) { ptaDeclaration Delaration = new ptaDeclaration(); Delaration.ApplicantName = model.ApplicantName; Delaration.ParentName = model.ParentName; if (!string.IsNullOrEmpty(model.Date)) { Delaration.Date = DateTime.ParseExact(model.Date, "dd/MM/yyyy", CultureInfo.InvariantCulture); } Delaration.ptaRegistrationInfoId = PilotRegister.Id; _context.ptaDeclarations.Add(Delaration); } var BoardOrUniversity = _context.ptaBoardAndUniversityMasters.Where(u => u.IsActive).ToList(); if (!string.IsNullOrEmpty(model.Tenth_BoardAndUniversity)) { ptaEducationDetail HighSchoolInfo = new ptaEducationDetail(); HighSchoolInfo.Class = "10th"; HighSchoolInfo.NameOfInstitute = model.Tenth_NameOfInstitute; HighSchoolInfo.ptaBoardAndUniversityMasterId = BoardOrUniversity.Where(b => b.Name == model.Tenth_BoardAndUniversity).FirstOrDefault().Id; HighSchoolInfo.YearOfPassing = model.Tenth_YearOfPassing; HighSchoolInfo.ptaEduEvaluationTypeMasterId = Convert.ToInt32((EvaluationType)Enum.Parse(typeof(EvaluationType), model.Tenth_EvaluationType.Replace(" ", string.Empty))); HighSchoolInfo.PercentageOrCGPA = model.Tenth_PercentageOrCGPA; HighSchoolInfo.ptaRegistrationInfoId = PilotRegister.Id; _context.ptaEducationDetails.Add(HighSchoolInfo); } ptaEducationDetail InterMediateInfo = new ptaEducationDetail(); if (!string.IsNullOrEmpty(model.Twelve_BoardAndUniversity)) { InterMediateInfo.Class = "12th"; InterMediateInfo.NameOfInstitute = model.Twelve_NameOfInstitute; InterMediateInfo.ptaBoardAndUniversityMasterId = BoardOrUniversity.Where(b => b.Name == model.Twelve_BoardAndUniversity).FirstOrDefault().Id; InterMediateInfo.ptaStreamMasterId = Convert.ToInt32((Stream)Enum.Parse(typeof(Stream), model.Twelve_Stream)); InterMediateInfo.YearOfPassing = model.Twelve_YearOfPassing; if (!string.IsNullOrEmpty(model.Twelve_EvaluationType)) { InterMediateInfo.ptaEduEvaluationTypeMasterId = Convert.ToInt32((EvaluationType)Enum.Parse(typeof(EvaluationType), model.Twelve_EvaluationType.Replace(" ", string.Empty))); } if (model.Twelve_PercentageOrCGPA > 0) { InterMediateInfo.PercentageOrCGPA = model.Twelve_PercentageOrCGPA; } if (!string.IsNullOrEmpty(model.Twelve_ResultStatus)) { InterMediateInfo.ptaResultStatusMasterId = Convert.ToInt32((ResultStatus)Enum.Parse(typeof(ResultStatus), model.Twelve_ResultStatus)); } InterMediateInfo.ptaRegistrationInfoId = PilotRegister.Id; _context.ptaEducationDetails.Add(InterMediateInfo); } if (!string.IsNullOrEmpty(model.UG_BoardAndUniversity)) { ptaEducationDetail UGInfo = new ptaEducationDetail(); UGInfo.Class = "UG"; UGInfo.NameOfInstitute = model.UG_NameOfInstitute; if (!string.IsNullOrEmpty(model.UG_BoardAndUniversity)) { UGInfo.ptaUGBoardAndUniversityMasterId = _context.ptaUGBoardAndUniversityMasters.Where(b => b.IsActive && b.Name == model.UG_BoardAndUniversity).FirstOrDefault().Id; } if (!string.IsNullOrEmpty(model.UG_YearOfPassing)) { UGInfo.YearOfPassing = model.UG_YearOfPassing; } if (!string.IsNullOrEmpty(model.UG_EvaluationType)) { UGInfo.ptaEduEvaluationTypeMasterId = Convert.ToInt32((EvaluationType)Enum.Parse(typeof(EvaluationType), model.UG_EvaluationType.Replace(" ", string.Empty))); } UGInfo.PercentageOrCGPA = model.UG_PercentageOrCGPA; if (!string.IsNullOrEmpty(model.UG_ResultStatus)) { UGInfo.ptaResultStatusMasterId = Convert.ToInt32((ResultStatus)Enum.Parse(typeof(ResultStatus), model.UG_ResultStatus)); } UGInfo.ptaRegistrationInfoId = PilotRegister.Id; _context.ptaEducationDetails.Add(UGInfo); } _context.SaveChanges(); if (InterMediateInfo.Id > 0) { ptaEducationSubjectMark Physics = new ptaEducationSubjectMark { SubjectName = "Physics", MaximumMark = model.MaxMarksOfPhysics, ObtainMark = model.ObtainMarksOfPhysics, Percentage = model.PercentageOfPhysics, ptaEducationDetailId = InterMediateInfo.Id }; _context.ptaEducationSubjectMarks.Add(Physics); ptaEducationSubjectMark English = new ptaEducationSubjectMark { SubjectName = "English", MaximumMark = model.MaxMarksOfEnglish, ObtainMark = model.ObtainMarksOfEnglish, Percentage = model.PercentageOfEnglish, ptaEducationDetailId = Physics.ptaEducationDetailId }; _context.ptaEducationSubjectMarks.Add(English); ptaEducationSubjectMark Math = new ptaEducationSubjectMark { SubjectName = "Math", MaximumMark = model.MaxMarksOfMath, ObtainMark = model.ObtainMarksOfMath, Percentage = model.PercentageOfMath, ptaEducationDetailId = English.ptaEducationDetailId }; _context.ptaEducationSubjectMarks.Add(Math); _context.SaveChanges(); } model.RegistrationNo = PilotRegister.RegistartionNo; return(model); }