|
|
- 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);
- }
- }
- }
|