public IActionResult Delete(int id) { PostingEvent PostingToDelete = _context.Postings.SingleOrDefault(Posting => Posting.PostingId == id); _context.Postings.Remove(PostingToDelete); _context.SaveChanges(); return(RedirectToAction("Home")); }
public IActionResult Posting(int postId) { if (HttpContext.Session.GetInt32("UserId") == null) { return(RedirectToAction("Index")); } ViewBag.Id = HttpContext.Session.GetInt32("UserId"); PostingEvent posting = _context.Postings.Where(w => w.PostingId == postId).FirstOrDefault(); ViewBag.posting = posting; List <PostingEvent> guests = _context.Postings.Where(w => w.PostingId == postId).Include(u => u.Creator).Include(u => u.Guests).ThenInclude(u => u.User).ToList(); ViewBag.Guests = guests; return(View()); }
public IActionResult Edit(int id, PostingEvent UpdatedPost) { PostingEvent PostToUpdate = _context.Postings.FirstOrDefault(PostingEvent => PostingEvent.PostingId == id); PostToUpdate.Company = UpdatedPost.Company; PostToUpdate.DateApply = UpdatedPost.DateApply; PostToUpdate.JobLink = UpdatedPost.JobLink; PostToUpdate.JobPosting = UpdatedPost.JobPosting; PostToUpdate.PositionTitle = UpdatedPost.PositionTitle; PostToUpdate.Notes = UpdatedPost.Notes; // PostToUpdate.JobLocation = UpdatedPost.JobLocation; PostToUpdate.RecruiterName = UpdatedPost.RecruiterName; PostToUpdate.ContactName = UpdatedPost.ContactName; PostToUpdate.PhoneScreen = UpdatedPost.PhoneScreen; PostToUpdate.ScreenNotes = UpdatedPost.ScreenNotes; PostToUpdate.Interview = UpdatedPost.Interview; PostToUpdate.InterviewNotes = UpdatedPost.InterviewNotes; PostToUpdate.PhoneInterview = UpdatedPost.PhoneInterview; PostToUpdate.PhoneNotes = UpdatedPost.PhoneNotes; PostToUpdate.Denied = UpdatedPost.Denied; PostToUpdate.DeniedNotes = UpdatedPost.DeniedNotes; PostToUpdate.ScreenEmail = UpdatedPost.ScreenEmail; PostToUpdate.ScreenLetter = UpdatedPost.ScreenLetter; PostToUpdate.ScreenCall = UpdatedPost.ScreenCall; PostToUpdate.PhoneEmail = UpdatedPost.PhoneEmail; PostToUpdate.PhoneLetter = UpdatedPost.PhoneLetter; PostToUpdate.PhoneCall = UpdatedPost.PhoneCall; PostToUpdate.InterviewEmail = UpdatedPost.InterviewEmail; PostToUpdate.InterviewLetter = UpdatedPost.InterviewLetter; PostToUpdate.InterviewCall = UpdatedPost.InterviewCall; PostToUpdate.DeniedEmail = UpdatedPost.DeniedEmail; PostToUpdate.DeniedLetter = UpdatedPost.DeniedLetter; PostToUpdate.DeniedCall = UpdatedPost.DeniedCall; PostToUpdate.ConfirmationEmail = UpdatedPost.ConfirmationEmail; PostToUpdate.UpdatedAt = DateTime.Now; _context.SaveChanges(); return(RedirectToAction("Home")); }
public IActionResult Update(int id) { PostingEvent PostToUpdate = _context.Postings.FirstOrDefault(PostingEvent => PostingEvent.PostingId == id); return(View("Edit", PostToUpdate)); }
public IActionResult CreatePosting(PostingEvent newposting) { newposting.CreatorId = (int)HttpContext.Session.GetInt32("UserId"); _context.Add(newposting); // OR dbContext.Goods.Add(newGood); _context.SaveChanges(); return(RedirectToAction("Home")); // if(HttpContext.Session.GetInt32("UserId") == null){ // return RedirectToAction("Index"); // } // var nh = DateTime.Now.Hour; // var nm = DateTime.Now.Minute; // if (newposting.DateApply > DateTime.Today){ // User user = _context.Users.Where(u => u.Id == (HttpContext.Session.GetInt32("UserId"))).FirstOrDefault(); // if (ModelState.IsValid){ // PostingEvent creatingposting = new PostingEvent(){ // Creator = user, // CreatorId = user.Id, // Company = newposting.Company, // DateApply = newposting.DateApply, // JobLink = newposting.JobLink, // JobPosting = newposting.JobPosting, // PositionTitle = newposting.PositionTitle, // Notes = newposting.Notes, // RecruiterName = newposting.RecruiterName, // ContactName = newposting.ContactName, // PhoneScreen = newposting.PhoneScreen, // ScreenNotes = newposting.ScreenNotes, // PhoneInterview = newposting.PhoneInterview, // PhoneNotes = newposting.PhoneNotes, // Interview = newposting.Interview, // InterviewNotes = newposting.InterviewNotes, // Denied = newposting.Denied, // DeniedNotes = newposting.DeniedNotes, // }; // _context.Postings.Add(creatingposting); // _context.SaveChanges(); // return RedirectToAction("Posting", new {postId = creatingposting.PostingId}); // } // else{ // return View("AddPosting"); // } // } // else if (newposting.DateApply == DateTime.Today){ // User user = _context.Users.Where(u => u.Id == (HttpContext.Session.GetInt32("UserId"))).FirstOrDefault(); // if (ModelState.IsValid){ // PostingEvent creatingposting = new PostingEvent(){ // Creator = user, // CreatorId = user.Id, // Company = newposting.Company, // DateApply = newposting.DateApply, // JobLink = newposting.JobLink, // JobPosting = newposting.JobPosting, // PositionTitle = newposting.PositionTitle, // Notes = newposting.Notes, // RecruiterName = newposting.RecruiterName, // ContactName = newposting.ContactName, // PhoneScreen = newposting.PhoneScreen, // ScreenNotes = newposting.ScreenNotes, // PhoneInterview = newposting.PhoneInterview, // PhoneNotes = newposting.PhoneNotes, // Interview = newposting.Interview, // InterviewNotes = newposting.InterviewNotes, // Denied = newposting.Denied, // DeniedNotes = newposting.DeniedNotes, // }; // _context.Postings.Add(creatingposting); // _context.SaveChanges(); // return RedirectToAction("Posting", new {postId = creatingposting.PostingId}); // } // else{ // return View("AddPosting"); // } // } // else{ // TempData["Future"] = "Please enter a Time and Date in the future"; // return RedirectToAction("AddPosting"); // } }