Skip to content

Instantly share code, notes, and snippets.

@elderfo
Last active December 2, 2016 03:58
Show Gist options
  • Save elderfo/980c3267fad78f90e2710231dc6057c5 to your computer and use it in GitHub Desktop.
Save elderfo/980c3267fad78f90e2710231dc6057c5 to your computer and use it in GitHub Desktop.
Static keyword removed
using Project.Logic;
namespace Project.Controllers
{
public class ExampleController : Controller
{
private readonly User _userLogic = new User();
public JsonResult GetUser(Guid userId)
{
UserModel user = _userLogic.Get(userId);
return Json(user, JsonRequestBehavior.AllowGet);
}
}
}
using Project.Data; // enternal dependency
namespace Project.Logic
{
public class User
{
public UserModel Get(Guid userId)
{
using (var entities = new Entities()) {
// ...
}
}
public List<UserModel> Get(Func<Data.User, bool> predicate = null)
{
using (var entities = new Entities()) {
// ...
}
}
public UserModel Create(UserModel model) { ... }
public void Update(UserModel model) { ... }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment