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

10 years ago
  1. using System.Linq;
  2. using System.Web.Mvc;
  3. using Sevomin.Models.Repositories;
  4. namespace Sevomin.WebFrontend.Controllers
  5. {
  6. class AdsController : Controller
  7. {
  8. IAdRepository _adRepository;
  9. public AdsController() : this(AdRepository.Current)
  10. {
  11. }
  12. public AdsController(IAdRepository adRepository)
  13. {
  14. _adRepository = adRepository;
  15. }
  16. public ActionResult Ads(int id)
  17. {
  18. var ad = _adRepository.ListAll().SingleOrDefault(m => m.Id == id);
  19. if (ad == null)
  20. {
  21. return HttpNotFound();
  22. }
  23. return Redirect(ad.Link);
  24. }
  25. }
  26. }