public ActionResult NewAd(SimpleAd ad) { var userId = GetCurrentUserId(); ad.UserId = userId.Value; SimpleAdDb db = new SimpleAdDb(_connectionString); db.AddSimpleAd(ad); return(Redirect("/")); }
public ActionResult NewAd(SimpleAd ad) { SimpleAdDb db = new SimpleAdDb(Properties.Settings.Default.ConStr); db.AddSimpleAd(ad); string ids = ""; HttpCookie cookie = Request.Cookies["AdIds"]; if (cookie != null) { ids = $"{cookie.Value},"; } ids += ad.Id; Response.Cookies.Add(new HttpCookie("AdIds", ids)); return(Redirect("/")); }
public IActionResult NewAd(SimpleAd ad) { SimpleAdDb db = new SimpleAdDb(_connectionString); db.AddSimpleAd(ad); List <int> ids = HttpContext.Session.Get <List <int> >("ListingIds"); if (ids == null) { ids = new List <int>(); } ids.Add(ad.Id); HttpContext.Session.Set("ListingIds", ids); return(Redirect("/homesession/index")); }
public ActionResult NewAd(SimpleAd ad) { SimpleAdDb db = new SimpleAdDb(_connectionString); db.AddSimpleAd(ad); string ids = ""; var cookie = Request.Cookies["AdIds"]; if (cookie != null) { ids = $"{cookie},"; } ids += ad.Id; Response.Cookies.Append("AdIds", ids); return(Redirect("/")); }
public ActionResult NewAd(SimpleAd ad, IEnumerable <HttpPostedFileBase> adImages) { SimpleAdDb db = new SimpleAdDb(Properties.Settings.Default.ConStr); ad.Images = adImages? .Where(i => i != null) .Select(i => new Image { FileName = SaveFile(i) }); db.AddSimpleAd(ad); string ids = ""; var cookie = Request.Cookies["AdIds"]; if (cookie != null) { ids = $"{cookie.Value},"; } ids += ad.Id; Response.Cookies.Add(new HttpCookie("AdIds", ids)); return(Redirect("/")); }