public static void Main() { var server = new WebServer( 1337, new ControllerRouter(), new ResourceRouter()); using (var db = new ChushkaContext()) { if (!db.ProductTypes.Any()) { db.ProductTypes.Add(new ProductType { Name = "Food" }); db.ProductTypes.Add(new ProductType { Name = "Domestic" }); db.ProductTypes.Add(new ProductType { Name = "Health" }); db.ProductTypes.Add(new ProductType { Name = "Cosmetic" }); db.ProductTypes.Add(new ProductType { Name = "Other" }); db.SaveChanges(); } db.Database.Migrate(); } MvcEngine.Run(server); }
public bool RegisterUser() { var userRole = Role.User; using (var context = new ChushkaContext()) { if (!context.Users.Any()) { userRole = Role.Admin; } var result = context.Users.Add(new User() { Username = this.Username, Password = this.Password, Email = this.Email, FullName = this.FullName, Role = userRole }); context.SaveChanges(); return(true); } }
public User AuthenticateUser() { using (var context = new ChushkaContext()) { var userResult = from u in context.Users where u.Username == this.Username && u.Password == this.Password select u; return(userResult.FirstOrDefault()); } }
public User RetrieveFromSession() { var userId = _session.GetInt32("userId"); if (userId != 0) { using (var context = new ChushkaContext()) { var userResult = from u in context.Users where u.Id == userId select u; return(userResult.FirstOrDefault()); } } return(null); }
public UserService(ChushkaContext context, IHashService hashService) { this.context = context; this.hashService = hashService; }
public OrderService(ChushkaContext context) : base(context) { }
public UserService(ChushkaContext context) { this.context = context; }
protected BaseController() { this.db = new ChushkaContext(); }
public ProductsService(ChushkaContext context) { this.context = context; }
public ProductService(ChushkaContext context) : base(context) { }
protected BaseService(ChushkaContext context) { this.context = context; }