public IActionResult OnGet(int?id)
        {
            string tempId = _unitOfWork.Applicant.GetFirstOrDefault(a => a.ApplicantId == id).ApplicationUserId;

            name = _unitOfWork.ApplicationUser.GetFirstOrDefault(b => b.Id == tempId).FullName;

            JudgeQuestionsList = _unitOfWork.JudgeQuestions.GetAll(null, null, "Questions");

            ApplicationObj = new Application();

            if (id != null)
            {
                ApplicationObj = _unitOfWork.Application.GetFirstOrDefault(u => u.ApplicantId == id);
                if (ApplicationObj == null)
                {
                    return(NotFound());
                }
                ApplicantObj = _unitOfWork.Applicant.GetFirstOrDefault(u => u.ApplicantId == id);
                if (ApplicantObj == null)
                {
                    return(NotFound());
                }
            }
            return(Page());
        }
 public ActionResult Create(ApplicantFields applicantFields)
 {
     if (Request.IsAuthenticated)
     {
         try
         {
             ApplicantWeb.Models.Applicant applicant = new Models.Applicant(applicantFields);
             if (ModelState.IsValid)
             {
                 db.Applicants.Add(applicant);
                 db.SaveChanges();
                 return(Redirect(Url.Action("Details", "Applicants", new { id = applicant.ApplicantId })));
             }
             return(View(applicant));
         }
         catch
         {
             return(HttpNotFound());
         }
     }
     else
     {
         return(Redirect(Url.Action("Login", "Account")));
     }
 }
 public ActionResult Create(ApplicantFields applicantFields)
 {
     if (Request.IsAuthenticated)
     {
         try
         {
             ApplicantWeb.Models.Applicant applicant = new Models.Applicant(applicantFields);
             if (ModelState.IsValid)
             {
                 db.Applicants.Add(applicant);
                 db.SaveChanges();
                 return Redirect(Url.Action("Details", "Applicants", new { id = applicant.ApplicantId }));
             }
             return View(applicant);
         }
         catch
         {
             return HttpNotFound();
         }
     }
     else
     {
         return Redirect(Url.Action("Login", "Account"));
     }
 }
Example #4
0
        public void OnGet(int?id)
        {
            ApplicantObj = _unitOfWork.Applicant.GetFirstOrDefault(a => a.ApplicantId == id, "Business");

            var Pitches = _unitOfWork.Pitch.GetAll(null, p => p.OrderBy(q => q.PitchDate), "Application").Where(p => p.Application.ApplicantId == id);

            PitchList = Pitches;
        }
Example #5
0
        public IActionResult create(CreateNewAppVM vm)
        {
            Application a = new Application();

            a.ApplicantId         = vm.Applicant.ApplicantId;
            a.CreatedApp          = DateTime.Now;
            a.LastEdited          = DateTime.Now;
            a.Finished            = false;
            a.StatusOfApplication = "Unknown";

            Models.Applicant applicant = _db.Applicant.Where(xa => xa.ApplicantId == a.ApplicantId).Include(xq => xq.ApplicationUser).ThenInclude(xe => xe.Country).Include(xw => xw.University).FirstOrDefault();

            Info newInfo = new Info();

            newInfo.CitizenshipId = applicant.ApplicationUser.CountryId;
            newInfo.Citizenship   = _db.Country.Where(t => t.CountryId == newInfo.CitizenshipId).FirstOrDefault();
            a.Infos = newInfo;
            _db.Info.Add(newInfo);

            Contact newContact = new Contact();

            newContact.Email     = applicant.ApplicationUser.Email;
            newContact.Telephone = applicant.ApplicationUser.PhoneNumber;
            newContact.Country   = null;
            newContact.CountryId = null;
            a.Contacts           = newContact;
            _db.Contact.Add(newContact);

            Language newLang = new Language();

            a.Languages = newLang;
            _db.Language.Add(newLang);

            HomeInstitution newHI = new HomeInstitution();

            newHI.OfficialName     = applicant.University.Name;
            newHI.LevelOfEducation = applicant.StudyCycle;
            newHI.StudyProgramme   = applicant.StudyField;
            a.HomeInstitutions     = newHI;
            _db.HomeInstitution.Add(newHI);

            Other newOther = new Other();

            a.Others = newOther;
            _db.Other.Add(newOther);

            Documents newDocs = new Documents();

            a.Documents = newDocs;
            _db.Documents.Add(newDocs);

            _db.Application.Add(a);
            _db.SaveChanges();

            return(RedirectToAction("profile", "dashboard", new { id = applicant.ApplicantId }));
        }
        public IActionResult OnPost()
        {
            int category = 3;
            IEnumerable <Questions> questions = _unitOfWork.Questions.GetAll(c => c.QuestionCategoryId == category);

            string userId = Request.Form["userId"].ToString();

            BusinessObj      = new Business();
            BusinessObj.Name = Request.Form["10"];

            _unitOfWork.Business.Add(BusinessObj);
            _unitOfWork.Save();

            ApplicantObj = new Models.Applicant();
            ApplicantObj.ApplicationUserId = userId;
            ApplicantObj.BusinessId        = BusinessObj.Id;

            _unitOfWork.Applicant.Add(ApplicantObj);
            _unitOfWork.Save();


            ApplicationObj = new Application();
            ApplicationObj.ApplicationDate = DateTime.Now;

            ApplicationObj.ApplicantId = ApplicantObj.ApplicantId;
            ApplicationObj.StatusId    = 3;

            _unitOfWork.Application.Add(ApplicationObj);
            _unitOfWork.Save();


            foreach (var applicationQuestion in questions)
            {
                if (applicationQuestion.QuestionId != 10)
                {
                    responseObj               = new QuestionResponses();
                    responseObj.QuestionsId   = applicationQuestion.QuestionId;
                    responseObj.Response      = Request.Form[applicationQuestion.QuestionId.ToString()].ToString();
                    responseObj.ResponseDate  = DateTime.Today;
                    responseObj.ApplicationId = ApplicationObj.Id;
                    _unitOfWork.Responses.Add(responseObj);
                }
            }

            _unitOfWork.Save();
            return(RedirectToPage("./Completion"));
        }
        public IActionResult create(CreateNewNomVM vm, int offerId)
        {
            Nomination a = new Nomination();

            a.ApplicantId        = vm.ApplicantId;
            a.CreatedNom         = DateTime.Now;
            a.LastEdited         = DateTime.Now;
            a.OfferId            = offerId;
            a.Offer              = _db.Offer.Where(b => b.OfferId == offerId).Include(x => x.University).ThenInclude(q => q.Country).FirstOrDefault();
            a.StatusOfNomination = "Unknown";

            Models.Applicant applicant = _db.Applicant.Where(xa => xa.ApplicantId == a.ApplicantId).Include(xq => xq.ApplicationUser).ThenInclude(xe => xe.Country).Include(xw => xw.University).FirstOrDefault();

            _db.Nomination.Add(a);
            _db.SaveChanges();

            return(RedirectToAction("profile", "dashboard", new { id = vm.ApplicantId }));
        }
        public IActionResult unverified(string id)
        {
            Models.Applicant v      = _db.Applicant.Include(a => a.ApplicationUser).Where(a => a.ApplicantId == id).FirstOrDefault();
            string           status = "";

            if (v.Verified == false)
            {
                v.Verified = true;
                status     = "succesfully verified!";
            }
            _db.Applicant.Update(v);
            _db.SaveChanges();
            _notificationService.sendToApplicant(id, HttpContext.GetLoggedUser().Id, new IRO_UNMO.App.Subscription.NotificationVM()
            {
                Message = "Your account verification has been changed. Now you are " + status,
                Url     = "/applicant/dashboard/profile/" + id
            });
            return(RedirectToAction("review", "applicants", new { id = v.ApplicantId }));
        }
        public IActionResult docs(ViewNomVM model)
        {
            Nomination newNom = _db.Nomination.Where(a => a.NominationId == model.Nomination.NominationId).FirstOrDefault();

            Models.Applicant y = _db.Applicant.Where(x => x.ApplicantId == newNom.ApplicantId).Include(b => b.ApplicationUser).ThenInclude(c => c.Country).FirstOrDefault();

            if (ModelState.IsValid)
            {
                string uniqueFileNameLA   = null;
                string uniqueFileNamePASS = null;
                string uniqueFileNameWP   = null;
                string uniqueFileNameCV   = null;
                string uniqueFileNameEng  = null;
                string uniqueFileNameToR  = null;
                string uniqueFileNameML   = null;
                string uniqueFileNameRL   = null;

                // If the Photo property on the incoming model object is not null, then the user
                // has selected an image to upload.
                if (model.LearningAgreement != null)
                {
                    string fileExt = Path.GetExtension(model.LearningAgreement.FileName);
                    if (fileExt == ".pdf")
                    {
                        // The image must be uploaded to the images folder in wwwroot
                        // To get the path of the wwwroot folder we are using the inject
                        // HostingEnvironment service provided by ASP.NET Core
                        string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                        // To make sure the file name is unique we are appending a new
                        // GUID value and and an underscore to the file name
                        uniqueFileNameLA = newNom.NominationId + "_" + model.LearningAgreement.FileName;
                        //uniqueFileNameLA = Guid.NewGuid().ToString() + "_" + model.LearningAgreement.FileName;
                        string filePath = Path.Combine(uploadsFolder, uniqueFileNameLA);
                        var    nesto    = new FileStream(filePath, FileMode.Create);
                        // Use CopyTo() method provided by IFormFile interface to
                        // copy the file to wwwroot/images folder
                        model.LearningAgreement.CopyTo(nesto);
                        nesto.Close();
                        newNom.LearningAgreement = uniqueFileNameLA;
                    }
                }

                if (model.WorkPlan != null)
                {
                    string fileExt = Path.GetExtension(model.WorkPlan.FileName);
                    if (fileExt == ".pdf")
                    {
                        string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                        uniqueFileNameWP = newNom.NominationId + "_" + model.WorkPlan.FileName;
                        string filePath = Path.Combine(uploadsFolder, uniqueFileNameWP);
                        var    nesto    = new FileStream(filePath, FileMode.Create);
                        // Use CopyTo() method provided by IFormFile interface to
                        // copy the file to wwwroot/images folder
                        model.WorkPlan.CopyTo(nesto);
                        nesto.Close();
                        newNom.WorkPlan = uniqueFileNameWP;
                    }
                }

                if (model.CV != null)
                {
                    string fileExt = Path.GetExtension(model.CV.FileName);
                    if (fileExt == ".pdf")
                    {
                        string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                        uniqueFileNameCV = newNom.NominationId + "_" + model.CV.FileName;
                        string filePath = Path.Combine(uploadsFolder, uniqueFileNameCV);
                        var    nesto    = new FileStream(filePath, FileMode.Create);
                        // Use CopyTo() method provided by IFormFile interface to
                        // copy the file to wwwroot/images folder
                        model.CV.CopyTo(nesto);
                        nesto.Close();
                        newNom.CV = uniqueFileNameCV;
                    }
                }

                if (model.Passport != null)
                {
                    string fileExt = Path.GetExtension(model.Passport.FileName);
                    if (fileExt == ".pdf")
                    {
                        string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                        uniqueFileNamePASS = newNom.NominationId + "_" + model.Passport.FileName;
                        string filePath = Path.Combine(uploadsFolder, uniqueFileNamePASS);
                        var    nesto    = new FileStream(filePath, FileMode.Create);
                        // Use CopyTo() method provided by IFormFile interface to
                        // copy the file to wwwroot/images folder
                        model.Passport.CopyTo(nesto);
                        nesto.Close();
                        newNom.Passport = uniqueFileNamePASS;
                    }
                }

                if (model.EngProficiency != null)
                {
                    string fileExt = Path.GetExtension(model.EngProficiency.FileName);
                    if (fileExt == ".pdf")
                    {
                        string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                        uniqueFileNameEng = newNom.NominationId + "_" + model.EngProficiency.FileName;
                        string filePath = Path.Combine(uploadsFolder, uniqueFileNameEng);
                        var    nesto    = new FileStream(filePath, FileMode.Create);
                        // Use CopyTo() method provided by IFormFile interface to
                        // copy the file to wwwroot/images folder
                        model.EngProficiency.CopyTo(nesto);
                        nesto.Close();
                        newNom.EngProficiency = uniqueFileNameEng;
                    }
                }

                if (model.TranscriptOfRecords != null)
                {
                    string fileExt = Path.GetExtension(model.TranscriptOfRecords.FileName);
                    if (fileExt == ".pdf")
                    {
                        string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                        uniqueFileNameToR = newNom.NominationId + "_" + model.TranscriptOfRecords.FileName;
                        string filePath = Path.Combine(uploadsFolder, uniqueFileNameToR);
                        var    nesto    = new FileStream(filePath, FileMode.Create);
                        // Use CopyTo() method provided by IFormFile interface to
                        // copy the file to wwwroot/images folder
                        model.TranscriptOfRecords.CopyTo(nesto);
                        nesto.Close();
                        newNom.TranscriptOfRecords = uniqueFileNameToR;
                    }
                }

                if (model.MotivationLetter != null)
                {
                    string fileExt = Path.GetExtension(model.MotivationLetter.FileName);
                    if (fileExt == ".pdf")
                    {
                        string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                        uniqueFileNameML = newNom.NominationId + "_" + model.MotivationLetter.FileName;
                        string filePath = Path.Combine(uploadsFolder, uniqueFileNameML);
                        var    nesto    = new FileStream(filePath, FileMode.Create);
                        // Use CopyTo() method provided by IFormFile interface to
                        // copy the file to wwwroot/images folder
                        model.MotivationLetter.CopyTo(nesto);
                        nesto.Close();
                        newNom.MotivationLetter = uniqueFileNameML;
                    }
                }

                if (model.ReferenceLetter != null)
                {
                    string fileExt = Path.GetExtension(model.ReferenceLetter.FileName);
                    if (fileExt == ".pdf")
                    {
                        string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                        uniqueFileNameRL = newNom.NominationId + "_" + model.ReferenceLetter.FileName;
                        string filePath = Path.Combine(uploadsFolder, uniqueFileNameRL);
                        var    nesto    = new FileStream(filePath, FileMode.Create);
                        // Use CopyTo() method provided by IFormFile interface to
                        // copy the file to wwwroot/images folder
                        model.ReferenceLetter.CopyTo(nesto);
                        nesto.Close();
                        newNom.ReferenceLetter = uniqueFileNameRL;
                    }
                }

                newNom.LastEdited = DateTime.Now;
                _db.SaveChanges();

                return(RedirectToAction("view", "nomination", new { id = newNom.NominationId }));
            }
            return(View());
        }
        public IActionResult docs(EditDocsVM model)
        {
            Application newApp = _db.Application.Where(a => a.ApplicationId == model.ApplicationId).Include(b => b.Infos).ThenInclude(q => q.Citizenship).Include(c => c.Contacts).Include(d => d.HomeInstitutions).Include(e => e.Others).FirstOrDefault();

            Models.Applicant y    = _db.Applicant.Where(x => x.ApplicantId == newApp.ApplicantId).Include(b => b.ApplicationUser).ThenInclude(c => c.Country).FirstOrDefault();
            Documents        docs = _db.Application.Where(a => a.ApplicationId == newApp.ApplicationId).Include(b => b.Documents).FirstOrDefault().Documents;

            if (ModelState.IsValid)
            {
                string uniqueFileNameLA   = null;
                string uniqueFileNameCV   = null;
                string uniqueFileNamePass = null;
                string uniqueFileNameEng  = null;
                string uniqueFileNameToR  = null;
                string uniqueFileNameML   = null;
                string uniqueFileNameRL   = null;
                string uniqueFileNameLAH  = null;
                string uniqueFileNameCOA  = null;
                string uniqueFileNameToRH = null;
                string uniqueFileNameExSR = null;
                string uniqueFileNameCOD  = null;

                // If the Photo property on the incoming model object is not null, then the user
                // has selected an image to upload.
                if (model.LearningAgreement != null)
                {
                    // The image must be uploaded to the images folder in wwwroot
                    // To get the path of the wwwroot folder we are using the inject
                    // HostingEnvironment service provided by ASP.NET Core
                    string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                    // To make sure the file name is unique we are appending a new
                    // GUID value and and an underscore to the file name
                    uniqueFileNameLA = newApp.ApplicationId + "_" + model.LearningAgreement.FileName;
                    //uniqueFileNameLA = Guid.NewGuid().ToString() + "_" + model.LearningAgreement.FileName;
                    string filePath = Path.Combine(uploadsFolder, uniqueFileNameLA);
                    string fileExt  = Path.GetExtension(uniqueFileNameLA);
                    var    nesto    = new FileStream(filePath, FileMode.Create);
                    // Use CopyTo() method provided by IFormFile interface to
                    // copy the file to wwwroot/images folder
                    model.LearningAgreement.CopyTo(nesto);
                    nesto.Close();
                    docs.LearningAgreement = uniqueFileNameLA;
                }

                if (model.CV != null)
                {
                    string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                    uniqueFileNameCV = newApp.ApplicationId + "_" + model.CV.FileName;
                    string filePath = Path.Combine(uploadsFolder, uniqueFileNameCV);
                    var    nesto    = new FileStream(filePath, FileMode.Create);
                    model.CV.CopyTo(nesto);
                    nesto.Close();
                    docs.CV = uniqueFileNameCV;
                }

                if (model.Passport != null)
                {
                    string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                    uniqueFileNamePass = newApp.ApplicationId + "_" + model.Passport.FileName;
                    string filePath = Path.Combine(uploadsFolder, uniqueFileNamePass);
                    var    nesto    = new FileStream(filePath, FileMode.Create);
                    model.Passport.CopyTo(nesto);
                    nesto.Close();
                    docs.Passport = uniqueFileNamePass;
                }

                if (model.EngProficiency != null)
                {
                    string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                    uniqueFileNameEng = newApp.ApplicationId + "_" + model.EngProficiency.FileName;
                    string filePath = Path.Combine(uploadsFolder, uniqueFileNameEng);
                    var    nesto    = new FileStream(filePath, FileMode.Create);
                    model.EngProficiency.CopyTo(nesto);
                    nesto.Close();
                    docs.EngProficiency = uniqueFileNameEng;
                }

                if (model.TranscriptOfRecords != null)
                {
                    string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                    uniqueFileNameToR = newApp.ApplicationId + "_" + model.TranscriptOfRecords.FileName;
                    string filePath = Path.Combine(uploadsFolder, uniqueFileNameToR);
                    var    nesto    = new FileStream(filePath, FileMode.Create);
                    model.TranscriptOfRecords.CopyTo(nesto);
                    nesto.Close();
                    docs.TranscriptOfRecords = uniqueFileNameToR;
                }

                if (model.MotivationLetter != null)
                {
                    string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                    uniqueFileNameML = newApp.ApplicationId + "_" + model.MotivationLetter.FileName;
                    string filePath = Path.Combine(uploadsFolder, uniqueFileNameML);
                    var    nesto    = new FileStream(filePath, FileMode.Create);
                    model.MotivationLetter.CopyTo(nesto);
                    nesto.Close();
                    docs.MotivationLetter = uniqueFileNameML;
                }

                if (model.ReferenceLetter != null)
                {
                    string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                    uniqueFileNameRL = newApp.ApplicationId + "_" + model.ReferenceLetter.FileName;
                    string filePath = Path.Combine(uploadsFolder, uniqueFileNameRL);
                    var    nesto    = new FileStream(filePath, FileMode.Create);
                    model.ReferenceLetter.CopyTo(nesto);
                    nesto.Close();
                    docs.ReferenceLetter = uniqueFileNameRL;
                }

                if (model.LearningAgreementHost != null)
                {
                    string fileExt = Path.GetExtension(model.LearningAgreementHost.FileName);
                    if (fileExt == ".pdf")
                    {
                        string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                        uniqueFileNameLAH = newApp.ApplicationId + "_" + model.LearningAgreementHost.FileName;
                        string filePath = Path.Combine(uploadsFolder, uniqueFileNameLAH);
                        var    nesto    = new FileStream(filePath, FileMode.Create);
                        model.LearningAgreementHost.CopyTo(nesto);
                        nesto.Close();
                        docs.LearningAgreementHost = uniqueFileNameLAH;
                    }
                }

                if (model.CertificateOfArrival != null)
                {
                    string fileExt = Path.GetExtension(model.CertificateOfArrival.FileName);
                    if (fileExt == ".pdf")
                    {
                        string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                        uniqueFileNameCOA = newApp.ApplicationId + "_" + model.CertificateOfArrival.FileName;
                        string filePath = Path.Combine(uploadsFolder, uniqueFileNameCOA);
                        var    nesto    = new FileStream(filePath, FileMode.Create);
                        model.CertificateOfArrival.CopyTo(nesto);
                        nesto.Close();
                        docs.CertificateOfArrival = uniqueFileNameCOA;
                    }
                }

                if (model.CertificateOfDeparture != null)
                {
                    string fileExt = Path.GetExtension(model.CertificateOfDeparture.FileName);
                    if (fileExt == ".pdf")
                    {
                        string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                        uniqueFileNameCOD = newApp.ApplicationId + "_" + model.CertificateOfDeparture.FileName;
                        string filePath = Path.Combine(uploadsFolder, uniqueFileNameCOD);
                        var    nesto    = new FileStream(filePath, FileMode.Create);
                        model.CertificateOfDeparture.CopyTo(nesto);
                        nesto.Close();
                        docs.CertificateOfDeparture = uniqueFileNameCOD;
                    }
                }

                if (model.StudentRecordSheet != null)
                {
                    string fileExt = Path.GetExtension(model.StudentRecordSheet.FileName);
                    if (fileExt == ".pdf")
                    {
                        string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                        uniqueFileNameExSR = newApp.ApplicationId + "_" + model.StudentRecordSheet.FileName;
                        string filePath = Path.Combine(uploadsFolder, uniqueFileNameExSR);
                        var    nesto    = new FileStream(filePath, FileMode.Create);
                        model.StudentRecordSheet.CopyTo(nesto);
                        nesto.Close();
                        docs.StudentRecordSheet = uniqueFileNameExSR;
                    }
                }

                if (model.StudentTranscriptOfRecords != null)
                {
                    string fileExt = Path.GetExtension(model.StudentTranscriptOfRecords.FileName);
                    if (fileExt == ".pdf")
                    {
                        string uploadsFolder = Path.Combine(hosting.WebRootPath, "uploads");
                        uniqueFileNameToRH = newApp.ApplicationId + "_" + model.StudentTranscriptOfRecords.FileName;
                        string filePath = Path.Combine(uploadsFolder, uniqueFileNameToRH);
                        var    nesto    = new FileStream(filePath, FileMode.Create);
                        model.StudentTranscriptOfRecords.CopyTo(nesto);
                        nesto.Close();
                        docs.StudentTranscriptOfRecords = uniqueFileNameToRH;
                    }
                }

                _db.SaveChanges();
                return(RedirectToAction("docs", "application", new { id = newApp.ApplicationId }));
            }

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

            Models.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;

            if (vm.Application.Others.MedicalInfo == null)
            {
                other.MedicalInfo = "none";
            }
            else
            {
                other.MedicalInfo = vm.Application.Others.MedicalInfo;
            }
            if (vm.Application.Others.AdditionalRequests == null)
            {
                other.AdditionalRequests = "none";
            }
            else
            {
                other.AdditionalRequests = vm.Application.Others.AdditionalRequests;
            }

            _db.SaveChanges();
            return(RedirectToAction("profile", "dashboard", new { id = newApp.ApplicantId }));
        }