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);
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
 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());
     }
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 public UserService(ChushkaContext context, IHashService hashService)
 {
     this.context     = context;
     this.hashService = hashService;
 }
Exemplo n.º 6
0
 public OrderService(ChushkaContext context)
     : base(context)
 {
 }
Exemplo n.º 7
0
 public UserService(ChushkaContext context)
 {
     this.context = context;
 }
Exemplo n.º 8
0
 protected BaseController()
 {
     this.db = new ChushkaContext();
 }
Exemplo n.º 9
0
 public ProductsService(ChushkaContext context)
 {
     this.context = context;
 }
Exemplo n.º 10
0
 public ProductService(ChushkaContext context)
     : base(context)
 {
 }
Exemplo n.º 11
0
 protected BaseService(ChushkaContext context)
 {
     this.context = context;
 }