public IActionResult comment(ViewNomVM model) { Nomination current = _db.Nomination.Where(a => a.NominationId == model.Nomination.NominationId).Include(a => a.University).FirstOrDefault(); if (model.NewComment != null) { Comment newComment = new Comment(); newComment.Message = model.NewComment; newComment.ApplicantId = HttpContext.GetLoggedUser().Id; newComment.IonId = current.NominationId; newComment.CommentTime = DateTime.Now; var admini = _db.Administrator.Include(a => a.ApplicationUser).ToList(); foreach (var x in admini) { _notificationService.sendToAdmin(x.AdministratorId, HttpContext.GetLoggedUser().Id, new IRO_UNMO.App.Subscription.NotificationVM() { Message = model.NewComment, Url = "/admin/nomination/view/" + current.NominationId }); } _db.Comment.Add(newComment); _db.SaveChanges(); } else { return(RedirectToAction("view", "nomination", new { id = model.Nomination.NominationId })); } return(RedirectToAction("view", "nomination", new { id = model.Nomination.NominationId })); }
public IActionResult status(ViewNomVM model) { Nomination current = _db.Nomination.Where(a => a.NominationId == model.Nomination.NominationId).Include(a => a.University).FirstOrDefault(); current.StatusOfNomination = model.Nomination.StatusOfNomination; _db.SaveChanges(); return(RedirectToAction("view", "nomination", new { id = model.Nomination.NominationId })); }
public IActionResult AddComment(int id) { ViewNomVM model = new ViewNomVM(); model.Nomination = _db.Nomination.Where(a => a.NominationId == id).FirstOrDefault(); model.Applicant = _db.Applicant.Where(a => a.ApplicantId == model.Nomination.ApplicantId).FirstOrDefault(); model.Comments = _db.Comment.Where(x => x.IonId == id).ToList(); return(View("AddComment", model)); }
public IActionResult comment(int id) { TempData["applicantId"] = HttpContext.GetLoggedUser().Id; ViewNomVM model = new ViewNomVM(); model.Nomination = _db.Nomination.Where(a => a.NominationId == id).FirstOrDefault(); model.Applicant = _db.Applicant.Where(a => a.ApplicantId == model.Nomination.ApplicantId).FirstOrDefault(); model.Comments = _db.Comment.Where(x => x.IonId == id).ToList(); return(View("comment", model)); }
public IActionResult status(ViewNomVM model) { Nomination current = _db.Nomination.Where(a => a.NominationId == model.Nomination.NominationId).Include(a => a.University).FirstOrDefault(); current.StatusOfNomination = model.Nomination.StatusOfNomination; _db.SaveChanges(); _notificationService.sendToApplicant(current.ApplicantId, HttpContext.GetLoggedUser().Id, new IRO_UNMO.App.Subscription.NotificationVM() { Message = "Your nomination status has been changed. New status is " + model.Nomination.StatusOfNomination + ".", Url = "/applicant/nomination/view/" + current.NominationId }); return(RedirectToAction("view", "nomination", new { id = model.Nomination.NominationId })); }
public IActionResult submit(ViewNomVM model) { Nomination current = _db.Nomination.Where(a => a.NominationId == model.Nomination.NominationId).Include(q => q.Applicant).ThenInclude(w => w.ApplicationUser).Include(a => a.University).FirstOrDefault(); current.Finished = true; current.FinishedTime = DateTime.Now; var admini = _db.Administrator.Include(a => a.ApplicationUser).ToList(); foreach (var x in admini) { _notificationService.sendToAdmin(x.AdministratorId, HttpContext.GetLoggedUser().Id, new IRO_UNMO.App.Subscription.NotificationVM() { Message = "Nomination nr. " + current.NominationId + " has been submitted. Now you can review it!", Url = "/admin/nomination/view/" + current.NominationId }); } _db.SaveChanges(); return(RedirectToAction("view", "nomination", new { id = model.Nomination.NominationId })); }
public IActionResult view(int id) { TempData["applicantId"] = HttpContext.GetLoggedUser().Id; ViewNomVM model = new ViewNomVM(); model.Nomination = _db.Nomination.Where(a => a.NominationId == id).Include(a => a.Offer).ThenInclude(b => b.University).ThenInclude(c => c.Country).FirstOrDefault(); model.Applicant = _db.Applicant.Where(x => x.ApplicantId == model.Nomination.ApplicantId).Include(a => a.ApplicationUser).ThenInclude(b => b.Country).Include(c => c.University).FirstOrDefault(); model.Comments = _db.Comment.Where(x => x.IonId == id).Include(a => a.Applicant).ThenInclude(b => b.ApplicationUser).ToList(); model.Statuses = new List <SelectListItem>(); model.Statuses.Add(new SelectListItem() { Value = "Unknown", Text = "Unknown" }); model.Statuses.Add(new SelectListItem() { Value = "Review - on hold", Text = "Review - on hold" }); model.Statuses.Add(new SelectListItem() { Value = "Review - successful", Text = "Review - succesful" }); model.Statuses.Add(new SelectListItem() { Value = "Enrolled", Text = "Enrolled" }); model.Statuses.Add(new SelectListItem() { Value = "Suspended", Text = "Suspended" }); return(View("view", model)); }
public IActionResult view(int id) { ViewNomVM model = new ViewNomVM(); var put = hosting.ContentRootPath; model.Nomination = _db.Nomination.Where(a => a.NominationId == id).Include(q => q.Offer).ThenInclude(a => a.University).ThenInclude(d => d.Country).FirstOrDefault(); model.Applicant = _db.Applicant.Where(x => x.ApplicantId == model.Nomination.ApplicantId).Include(a => a.ApplicationUser).ThenInclude(b => b.Country).Include(c => c.University).FirstOrDefault(); model.Comments = _db.Comment.Where(x => x.IonId == id).ToList(); model.Statuses = new List <SelectListItem>(); model.Statuses.Add(new SelectListItem() { Value = "Unknown", Text = "Unknown" }); model.Statuses.Add(new SelectListItem() { Value = "Review - on hold", Text = "Review - on hold" }); model.Statuses.Add(new SelectListItem() { Value = "Review - successful", Text = "Review - succesful" }); model.Statuses.Add(new SelectListItem() { Value = "Enrolled", Text = "Enrolled" }); model.Statuses.Add(new SelectListItem() { Value = "Suspended", Text = "Suspended" }); return(View("view", model)); }
public IActionResult AddComment(ViewNomVM model) { Nomination current = _db.Nomination.Where(a => a.NominationId == model.Nomination.NominationId).Include(a => a.University).FirstOrDefault(); if (model.NewComment != null) { Comment newComment = new Comment(); newComment.Message = model.NewComment; newComment.ApplicantId = current.ApplicantId; newComment.IonId = current.NominationId; newComment.CommentTime = DateTime.Now; _db.Comment.Add(newComment); _db.SaveChanges(); } else { return(RedirectToAction("view", "nomination", new { id = model.Nomination.NominationId })); } return(RedirectToAction("view", "nomination", new { id = model.Nomination.NominationId })); }
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()); }