public IActionResult edit(int id) { EditAppVM model = _userManagementHelper.prepApp(); model.ApplicationId = id; model.Application = _db.Application.Where(a => a.ApplicationId == id).Include(b => b.Infos).ThenInclude(q => q.Citizenship).Include(c => c.Contacts).ThenInclude(q => q.Country).Include(d => d.HomeInstitutions).Include(e => e.Others).Include(f => f.Documents).Include(g => g.Languages).FirstOrDefault(); return(View("edit", model)); }
public IActionResult edit(EditAppVM vm) { Application newApp = _db.Application.Where(a => a.ApplicationId == vm.ApplicationId).Include(b => b.Infos).ThenInclude(q => q.Citizenship).Include(c => c.Contacts).Include(d => d.HomeInstitutions).Include(e => e.Others).FirstOrDefault(); Applicant y = _db.Applicant.Where(x => x.ApplicantId == newApp.ApplicantId).Include(b => b.ApplicationUser).ThenInclude(c => c.Country).FirstOrDefault(); Info info = _db.Application.Where(a => a.ApplicationId == newApp.ApplicationId).Include(b => b.Infos).FirstOrDefault().Infos; info.Gender = vm.Application.Infos.Gender; //info.CitizenshipId = vm.Application.Applicant.ApplicationUser.CountryId; //info.CitizenshipId = vm.Application.Infos.CitizenshipId; info.SecondCitizenshipId = vm.Application.Infos.SecondCitizenshipId; info.DateOfBirth = vm.Application.Infos.DateOfBirth; info.PlaceOfBirth = vm.Application.Infos.PlaceOfBirth; info.PassportNumber = vm.Application.Infos.PassportNumber; info.PassportIssueDate = vm.Application.Infos.PassportIssueDate; info.PassportExpiryDate = vm.Application.Infos.PassportExpiryDate; newApp.LastEdited = DateTime.Now; Contact contact = _db.Application.Where(a => a.ApplicationId == newApp.ApplicationId).Include(b => b.Contacts).FirstOrDefault().Contacts; //contact.Email = y.ApplicationUser.Email; //contact.Telephone = y.ApplicationUser.PhoneNumber; contact.StreetName = vm.Application.Contacts.StreetName; contact.PlaceName = vm.Application.Contacts.PlaceName; contact.PostalCode = vm.Application.Contacts.PostalCode; contact.CountryId = vm.Application.Contacts.CountryId; newApp.LastEdited = DateTime.Now; Language lang = _db.Application.Where(a => a.ApplicationId == newApp.ApplicationId).Include(b => b.Languages).FirstOrDefault().Languages; lang.Native = vm.Application.Languages.Native; lang.ForeignFirst = vm.Application.Languages.ForeignFirst; lang.ForeignFirstProficiency = vm.Application.Languages.ForeignFirstProficiency; lang.ForeignSecond = vm.Application.Languages.ForeignSecond; lang.ForeignSecondProficiency = vm.Application.Languages.ForeignSecondProficiency; lang.ForeignThird = vm.Application.Languages.ForeignThird; lang.ForeignThirdProficiency = vm.Application.Languages.ForeignThirdProficiency; lang.ForeignExperienceNumber = vm.Application.Languages.ForeignExperienceNumber; newApp.LastEdited = DateTime.Now; HomeInstitution homeInst = _db.Application.Where(a => a.ApplicationId == newApp.ApplicationId).Include(b => b.HomeInstitutions).FirstOrDefault().HomeInstitutions; //homeInst.OfficialName = _db.Applicant.Where(a => a.ApplicantId == newApp.ApplicantId).FirstOrDefault().University.Name; //homeInst.OfficialName = vm.Application.HomeInstitutions.OfficialName; homeInst.DepartmentName = vm.Application.HomeInstitutions.DepartmentName; //homeInst.LevelOfEducation = vm.Application.HomeInstitutions.LevelOfEducation; homeInst.CurrentTermOrYear = vm.Application.HomeInstitutions.CurrentTermOrYear; //homeInst.StudyProgramme = vm.Application.HomeInstitutions.StudyProgramme; homeInst.CoordinatorFullName = vm.Application.HomeInstitutions.CoordinatorFullName; homeInst.CoordinatorPosition = vm.Application.HomeInstitutions.CoordinatorPosition; homeInst.CoordinatorEmail = vm.Application.HomeInstitutions.CoordinatorEmail; homeInst.CoordinatorPhoneNum = vm.Application.HomeInstitutions.CoordinatorPhoneNum; homeInst.CoordinatorAddress = vm.Application.HomeInstitutions.CoordinatorAddress; Other other = _db.Application.Where(a => a.ApplicationId == newApp.ApplicationId).Include(b => b.Others).FirstOrDefault().Others; other.MedicalInfo = vm.Application.Others.MedicalInfo; other.AdditionalRequests = vm.Application.Others.AdditionalRequests; _db.SaveChanges(); return(RedirectToAction("details", "account", new { id = newApp.ApplicantId })); }
public EditAppVM prepApp() { EditAppVM model = new EditAppVM(); model.Languages = new List <SelectListItem>(); model.Languages.Add(new SelectListItem() { Value = "", Text = "" }); model.Languages.Add(new SelectListItem() { Value = "bosnian", Text = "bosnian" }); model.Languages.Add(new SelectListItem() { Value = "croatian", Text = "croatian" }); model.Languages.Add(new SelectListItem() { Value = "serbian", Text = "serbian" }); model.Languages.Add(new SelectListItem() { Value = "spanish", Text = "spanish" }); model.Genders = new List <SelectListItem>(); model.Genders.Add(new SelectListItem() { Value = "", Text = "" }); model.Genders.Add(new SelectListItem() { Value = "male", Text = "male" }); model.Genders.Add(new SelectListItem() { Value = "female", Text = "female" }); model.Genders.Add(new SelectListItem() { Value = "not specified", Text = "not specified" }); model.Countries = _db.Country.Select(x => new SelectListItem() { Value = x.CountryId.ToString(), Text = x.Name }).ToList(); model.Countries.Insert(0, new SelectListItem { Value = "", Text = "" }); model.StudyCycles = new List <SelectListItem>(); model.StudyCycles.Add(new SelectListItem() { Value = "", Text = "" }); model.StudyCycles.Add(new SelectListItem() { Value = "bachelor", Text = "bachelor" }); model.StudyCycles.Add(new SelectListItem() { Value = "master", Text = "master" }); model.StudyTerms = new List <SelectListItem>(); model.StudyTerms.Add(new SelectListItem() { Value = "", Text = "" }); model.StudyTerms.Add(new SelectListItem() { Value = "1st semester", Text = "1st semester" }); model.StudyTerms.Add(new SelectListItem() { Value = "2nd semester", Text = "2nd semester" }); model.StudyTerms.Add(new SelectListItem() { Value = "3rd semester", Text = "3rd semester" }); model.StudyTerms.Add(new SelectListItem() { Value = "4th semester", Text = "4th semester" }); model.StudyTerms.Add(new SelectListItem() { Value = "5th semester", Text = "5th semester" }); model.StudyTerms.Add(new SelectListItem() { Value = "6th semester", Text = "6th semester" }); model.StudyTerms.Add(new SelectListItem() { Value = "7th semester", Text = "7th semester" }); model.LangProfiency = new List <SelectListItem>(); model.LangProfiency.Add(new SelectListItem() { Value = "", Text = "" }); model.LangProfiency.Add(new SelectListItem() { Value = "A1 (Basic user)", Text = "A1 (Basic user)" }); model.LangProfiency.Add(new SelectListItem() { Value = "A2 (Basic user)", Text = "A2 (Basic user)" }); model.LangProfiency.Add(new SelectListItem() { Value = "B1 (Independent user)", Text = "B1 (Independent user)" }); model.LangProfiency.Add(new SelectListItem() { Value = "B2 (Independent user)", Text = "B2 (Independent user)" }); model.LangProfiency.Add(new SelectListItem() { Value = "C1 (Proficient user)", Text = "C1 (Proficient user)" }); model.LangProfiency.Add(new SelectListItem() { Value = "C2 (Proficient user)", Text = "C2 (Proficient user)" }); return(model); }