// GET: Ad/Details/5 public ActionResult ShowAds() { WorkStationDAL.Ads Ads = new WorkStationDAL.Ads(); List <WorkStationDAL.Ads> str = new List <WorkStationDAL.Ads>(); str = Ads.Ad("Website"); ViewBag.AdModel = str; return(View()); }
public ActionResult CreateAd(CreateAd model) { if (Session["Username"] != null) { System.IO.Stream stream = model.AdImg.InputStream; System.Drawing.Image image = System.Drawing.Image.FromStream(stream); if (image.Height > 330 || image.Width > 128) { return(RedirectToAction("CreateAdFailed", "Alert")); } string FullPath = AppDomain.CurrentDomain.BaseDirectory + System.Configuration.ConfigurationManager.AppSettings["ImgPath"] + @"\" + model.AdName + Session["Username"] + Path.GetExtension(model.AdImg.FileName); string PathInProject = System.Configuration.ConfigurationManager.AppSettings["ImgPath"] + @"\" + model.AdName + Session["Username"] + Path.GetExtension(model.AdImg.FileName); WorkStationDAL.Ads CAd = new WorkStationDAL.Ads(); if (CAd.CreateAd(model.AdName, model.AdDescription, PathInProject, Session["Username"].ToString(), model.ProjectPrice, model.ProjectType) != -1) { try { model.AdImg.SaveAs(FullPath); } catch { return(View("~/Views/Alert/CreateAdFailed.cshtml")); } } else { return(View("~/Views/Alert/CreateAdFailed.cshtml")); } } else { return(RedirectToAction("LogIn", "User")); } return(View()); }