// GET: PublicOffer public ActionResult OfferDetails(int?id) { JobOffer offer = this.Data.JobOffers.Find((int)id); if (id == null || offer == null) { return(this.RedirectToAction("SearchOffers", "SearchOffer")); } offer.Views += 1; this.Data.JobOffers.Update(offer); DetailsOfferViewModel model = this.Data.JobOffers.All().Where(o => o.Id == id) .Select(DetailsOfferViewModel.FromJobOffer).FirstOrDefault(); if (Request.IsAuthenticated && User.IsInRole("Person")) { string personId = this.User.Identity.GetUserId(); Application app = this.Data.Applications.All().Where(a => a.PersonId == personId && a.JobOfferId == model.Id) .Include("Person").FirstOrDefault(); this.TempData["HasApplied"] = (app == null) ? false : true; Person current = this.Data.People.Find(personId); if (offer.PeopleFollowing.Contains(current)) { this.TempData["FollowButtonText"] = "Unfollow"; } else { this.TempData["FollowButtonText"] = "Follow"; } } return(this.View(model)); }
public async Task <IActionResult> RemovedOffer(string id) { var offer = await this.offerService.GetOfferAnywayAsync(id); var category = await this.categoryService.GetCategoryNameByIdAsync(offer.CategoryId); var offerView = new OfferViewModelDetails() { CreatorId = offer.CreatorId, Description = offer.Description, Name = offer.Name, PicUrl = offer.PicUrl, Price = offer.Price, CreatedOn = offer.CreatedOn, Id = offer.Id, IsFeatured = offer.IsFeatured, }; var detailsModel = new DetailsOfferViewModel() { CategoryName = category, Offer = offerView, CategoryId = offer.CategoryId, }; return(this.View(detailsModel)); }
public ActionResult OfferDetails(int?id) { if (id == null) { return(this.RedirectToAction("GetOffers")); } string companyId = User.Identity.GetUserId(); DetailsOfferViewModel model = this.Data.JobOffers.All().Where(o => o.Id == id && o.CompanyId == companyId) .Select(DetailsOfferViewModel.FromJobOffer).FirstOrDefault(); if (model == null) { MessageViewModel message = new MessageViewModel { Text = "Job offer not found.", Type = MessageType.Error }; this.TempData["Message"] = message; return(this.RedirectToAction("GetOffers", "JobOffer")); // TempData["NotFound"] = "Job offer not found."; } return(this.View(model)); }