You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

29 lines
685 B

using System.Linq;
using System.Web.Mvc;
using Sevomin.Models.Repositories;
namespace Sevomin.WebFrontend.Controllers
{
class AdsController : Controller
{
IAdRepository _adRepository;
public AdsController() : this(AdRepository.Current)
{
}
public AdsController(IAdRepository adRepository)
{
_adRepository = adRepository;
}
public ActionResult Ads(int id)
{
var ad = _adRepository.ListAll().SingleOrDefault(m => m.Id == id);
if (ad == null)
{
return HttpNotFound();
}
return Redirect(ad.Link);
}
}
}