public ActionResult CreateFreelancer(Listing listing) { /* if (listing.AutoAcceptMax == null) { listing.AutoAcceptMax = 0; } if (listing.ExpirationDate == null) { listing.ExpirationDate = DateTime.MaxValue; } listing.LastActivity = DateTime.Today; */ if (ModelState.IsValid) { listing.Status = ListingStatus.Created; listing.Type = ListingType.Freelancer; /* listing.CreatorID = WebSecurity.GetUserId(User.Identity.Name); */ using (var dbContext = new UsersContext()) { var user = dbContext.UserProfiles.Find(WebSecurity.GetUserId(User.Identity.Name)); listing.CreatorID = user.UserId; listing.CreatorName = user.Name; listing.CreatorContact = user.Email; } db.Listings.Add(listing); db.SaveChanges(); return RedirectToAction("Search", "Listing"); } return View(listing); }
public ActionResult Edit(Listing listing) { /* if (listing.AutoAcceptMax == null) { listing.AutoAcceptMax = 0; } if (listing.ExpirationDate == null) { listing.ExpirationDate = DateTime.MaxValue; } listing.LastActivity = DateTime.Today; */ if (ModelState.IsValid) { listing.Status = ListingStatus.Created; listing.CreatorID = WebSecurity.GetUserId(User.Identity.Name); db.Entry(listing).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Search", "Listing"); } return View(listing); }