Skip to content

Instantly share code, notes, and snippets.

@eldewall
Created September 30, 2011 11:34
Show Gist options
  • Select an option

  • Save eldewall/1253500 to your computer and use it in GitHub Desktop.

Select an option

Save eldewall/1253500 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BBAdmin.Models;
using BBAdmin.DataAccess.DataHandler;
using BBAdmin.DataAccess;
using BBAdmin.Models.ViewModels;
namespace BBAdmin.Site.Controllers {
public abstract class PolyController<T> : Controller
where T : SalesObject {
public ActionResult Index() {
List<T> viewItems;
using(bb8Entities db = new bb8Entities()) {
viewItems = ObjectHandler.GetList<T>(740, db);
}
SalesObjectIndexModel model = new SalesObjectIndexModel(null, null, viewItems);
return View(model);
}
public abstract ISalesObjectHandler ObjectHandler { get; }
}
public class FooController : PolyController<Accessory> {
private FooAccessoryHandler _handler = new FooAccessoryHandler();
public override ISalesObjectHandler ObjectHandler {
get { return _handler; }
}
public ActionResult FooSpecific() {
return Json(new { id = 0 });
}
}
public class FooAccessoryHandler : SalesObjectHandler, ISalesObjectHandler {
public List<T> GetList<T>(int customerId, bb8Entities db) where T : SalesObject {
return base.GetList<T>(740, 7, "", PagingOptions.Default(), db, Populate);
}
private Accessory Populate(SalesObjectGetResult sogr) {
return new Accessory();
}
}
public interface ISalesObjectHandler {
List<T> GetList<T>(int customerId, bb8Entities db) where T : SalesObject;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment