public IActionResult create(string id) { CreateNewNomVM model = new CreateNewNomVM(); model.ApplicantId = id; model.Applicant = _db.Applicant.Where(a => a.ApplicantId == id).Include(b => b.ApplicationUser).ThenInclude(c => c.Country).FirstOrDefault(); model.Universities = _db.University.Select(x => new SelectListItem() { Value = x.UniversityId.ToString(), Text = x.Name }).ToList(); return(View("create", model)); }
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 create(CreateNewNomVM vm) { Nomination a = new Nomination(); a.ApplicantId = vm.ApplicantId; a.CreatedNom = DateTime.Now; a.LastEdited = DateTime.Now; a.UniversityId = vm.UniversityId; a.University = _db.University.Where(b => b.UniversityId == vm.UniversityId).FirstOrDefault(); a.StatusOfNomination = "Unknown"; Applicant applicant = _db.Applicant.Where(xa => xa.ApplicantId == vm.ApplicantId).Include(xq => xq.ApplicationUser).ThenInclude(xe => xe.Country).Include(xw => xw.University).FirstOrDefault(); _db.Nomination.Add(a); _db.SaveChanges(); return(RedirectToAction("details", "account", new { id = vm.ApplicantId })); }
public IActionResult create(string id) { TempData["applicantId"] = HttpContext.GetLoggedUser().Id; CreateNewNomVM model = new CreateNewNomVM(); model.ApplicantId = id; model.Applicant = _db.Applicant.Where(a => a.ApplicantId == id).Include(b => b.ApplicationUser).ThenInclude(c => c.Country).FirstOrDefault(); List <Offer> allOffers = _db.Offer.Include(a => a.University).ThenInclude(b => b.Country).Where(x => x.Start <= DateTime.Now && x.End >= DateTime.Now).OrderBy(a => a.Start).ToList(); List <Offer> userNominations = _db.Nomination.Where(a => a.ApplicantId == id).Select(q => q.Offer).OrderBy(a => a.Start).ToList(); List <Offer> offersWithoutNom = allOffers.Except(userNominations).ToList(); if (userNominations.Count() != 0 && userNominations.Count() <= allOffers.Count()) { model.Offers = offersWithoutNom; } else { model.Offers = allOffers; } return(View("create", model)); }