public void Setup()
        {
            var options = new DbContextOptionsBuilder <GolfDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            _context   = new GolfDbContext(options);
            _createdAt = DateTime.Now;
            var scores = new List <Score>()
            {
                new Score()
                {
                    Id          = new Guid("00000000-0000-0000-0000-000000000001"),
                    PlayerId    = new Guid("00000000-0000-0000-0001-000000000000"),
                    Value       = 45,
                    GolfRoundId = new Guid("00000000-0000-0001-0000-000000000000"),
                    Created     = _createdAt,
                },
                new Score()
                {
                    Id          = new Guid("00000000-0000-0000-0000-000000000002"),
                    PlayerId    = new Guid("00000000-0000-0000-0002-000000000000"),
                    Value       = 63,
                    GolfRoundId = new Guid("00000000-0000-0001-0000-000000000000"),
                    Created     = _createdAt,
                },
                new Score()
                {
                    Id          = new Guid("00000000-0000-0000-0000-000000000003"),
                    PlayerId    = new Guid("00000000-0000-0000-0001-000000000000"),
                    Value       = 40,
                    GolfRoundId = new Guid("00000000-0000-0002-0000-000000000000"),
                    Created     = _createdAt,
                },
                new Score()
                {
                    Id          = new Guid("00000000-0000-0000-0000-000000000004"),
                    PlayerId    = new Guid("00000000-0000-0000-0002-000000000000"),
                    Value       = 57,
                    GolfRoundId = new Guid("00000000-0000-0003-0000-000000000000"),
                    Created     = _createdAt,
                }
            }.AsQueryable();

            _context.Scores.AddRange(scores);
            _context.SaveChanges();
            _sut = new ScoreAccessLayer(_context);
        }
        public void Setup()
        {
            var options = new DbContextOptionsBuilder <GolfDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            _context    = new GolfDbContext(options);
            _createdAt  = DateTime.Now;
            _modifiedAt = DateTime.Now;
            var players = new List <Player>()
            {
                new Player()
                {
                    Id        = new Guid("00000000-0000-0000-0000-000000000001"),
                    UserId    = new Guid("00000000-0000-0000-0001-000000000000"),
                    FirstName = "Thashin",
                    LastName  = "Naidoo",
                    Handicap  = new Decimal(19.3),
                    Created   = _createdAt,
                    Modified  = _modifiedAt
                },
                new Player()
                {
                    Id        = new Guid("00000000-0000-0000-0000-000000000002"),
                    UserId    = new Guid("00000000-0000-0000-0002-000000000000"),
                    FirstName = "Michael",
                    LastName  = "Nelmes",
                    Handicap  = new Decimal(24.8),
                    Created   = _createdAt,
                    Modified  = _modifiedAt
                }
            }.AsQueryable();

            _context.Players.AddRange(players);
            _context.SaveChanges();
            var userOptions = new DbContextOptionsBuilder <ApplicationDbContext>()
                              .UseInMemoryDatabase(Guid.NewGuid().ToString())
                              .Options;
            var userContext = new ApplicationDbContext(userOptions);

            userContext.Add(new ApplicationUser()
            {
                Id = "00000000-0000-0000-0003-000000000000"
            });
            userContext.SaveChanges();
            _sut = new PlayerAccessLayer(_context, userContext);
        }
        public void Setup()
        {
            var options = new DbContextOptionsBuilder <GolfDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            _context   = new GolfDbContext(options);
            _createdAt = DateTime.Now;
            var golfRounds = new List <GolfRound>()
            {
                new GolfRound()
                {
                    Id       = new Guid("00000000-0000-0000-0000-000000000001"),
                    Date     = _createdAt,
                    CourseId = new Guid("00000000-0000-0000-0001-000000000000"),
                    Created  = _createdAt,
                },
                new GolfRound()
                {
                    Id       = new Guid("00000000-0000-0000-0000-000000000002"),
                    Date     = _createdAt,
                    CourseId = new Guid("00000000-0000-0000-0002-000000000000"),
                    Created  = _createdAt,
                },
                new GolfRound()
                {
                    Id       = new Guid("00000000-0000-0000-0000-000000000003"),
                    Date     = _createdAt,
                    CourseId = new Guid("00000000-0000-0000-0001-000000000000"),
                    Created  = _createdAt,
                },
                new GolfRound()
                {
                    Id       = new Guid("00000000-0000-0000-0000-000000000004"),
                    Date     = _createdAt,
                    CourseId = new Guid("00000000-0000-0000-0003-000000000000"),
                    Created  = _createdAt,
                },
            }.AsQueryable();

            _context.GolfRounds.AddRange(golfRounds);
            _context.SaveChanges();
            _sut = new GolfRoundAccessLayer(_context);
        }
Exemplo n.º 4
0
        public void Setup()
        {
            var options = new DbContextOptionsBuilder <GolfDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            _context   = new GolfDbContext(options);
            _createdAt = DateTime.Now;
            var Handicaps = new List <Handicap>()
            {
                new Handicap()
                {
                    Id              = new Guid("00000000-0000-0000-0000-000000000001"),
                    PlayerId        = new Guid("00000000-0000-0000-0001-000000000000"),
                    CurrentHandicap = 23,
                    Value           = 45,
                    Date            = _createdAt
                },
                new Handicap()
                {
                    Id              = new Guid("00000000-0000-0000-0000-000000000002"),
                    PlayerId        = new Guid("00000000-0000-0000-0002-000000000000"),
                    CurrentHandicap = 18,
                    Value           = 19,
                    Date            = _createdAt
                },
                new Handicap()
                {
                    Id              = new Guid("00000000-0000-0000-0000-000000000003"),
                    PlayerId        = new Guid("00000000-0000-0000-0001-000000000000"),
                    CurrentHandicap = 20,
                    Value           = 15,
                    Date            = _createdAt.AddDays(1)
                }
            }.AsQueryable();

            _context.Handicaps.AddRange(Handicaps);
            _context.SaveChanges();
            _sut = new HandicapAccessLayer(_context);
        }
Exemplo n.º 5
0
        protected void Application_Start()
        {
            Database.SetInitializer<GolfDbContext>(new GolfLeagueInitializer());
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var dbContext = new GolfDbContext();
            var configSettings = new ConfigRepository(dbContext).Get();
            Application.Add("HandicapWeeks", configSettings.HandicapWeekCount);
            Application.Add("HandicapRoundAdj", configSettings.RoundAdjustment);
            Application.Add("RoundParFront", configSettings.RoundParFront);
            Application.Add("RoundParBack", configSettings.RoundParBack);

            var courseSettings = new CourseRepository(dbContext).Get();
            var parRepo = new ParRespository(dbContext);
            var frontPars = parRepo.GetFrontPars(courseSettings.CourseId);
            var backPars = parRepo.GetBackPars(courseSettings.CourseId);
            Application.Add("FrontPars", frontPars);
            Application.Add("BackPars", backPars);
        }
        public void Setup()
        {
            var options = new DbContextOptionsBuilder <GolfDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            _context    = new GolfDbContext(options);
            _createdAt  = DateTime.Now;
            _modifiedAt = DateTime.Now;

            var players = new List <Player>()
            {
                new Player()
                {
                    Id        = new Guid("00000000-0000-0000-0000-000000000001"),
                    UserId    = new Guid("00000000-0000-0000-0001-000000000000"),
                    FirstName = "Thashin",
                    LastName  = "Naidoo",
                    Handicap  = new Decimal(19.3),
                    Created   = _createdAt,
                    Modified  = _modifiedAt
                },
                new Player()
                {
                    Id        = new Guid("00000000-0000-0000-0000-000000000002"),
                    UserId    = new Guid("00000000-0000-0000-0002-000000000000"),
                    FirstName = "Michael",
                    LastName  = "Nelmes",
                    Handicap  = new Decimal(24.8),
                    Created   = _createdAt,
                    Modified  = _modifiedAt
                },
                new Player()
                {
                    Id        = new Guid("00000000-0000-0000-0000-000000000003"),
                    UserId    = new Guid("00000000-0000-0000-0003-000000000000"),
                    FirstName = "Adam",
                    LastName  = "Van Halsdingen",
                    Handicap  = new Decimal(44.8),
                    Created   = _createdAt,
                    Modified  = _modifiedAt
                },
                new Player()
                {
                    Id        = new Guid("00000000-0000-0000-0000-000000000004"),
                    UserId    = new Guid("00000000-0000-0000-0004-000000000000"),
                    FirstName = "Jake",
                    LastName  = "Hannell",
                    Handicap  = null,
                    Created   = _createdAt,
                    Modified  = _modifiedAt
                }
            }.AsQueryable();

            var partners = new List <Partner>()
            {
                new Partner()
                {
                    Id        = new Guid("00000000-0000-0000-0000-000000000001"),
                    PlayerId  = new Guid("00000000-0000-0000-0000-000000000001"),
                    PartnerId = new Guid("00000000-0000-0000-0000-000000000002")
                },
                new Partner()
                {
                    Id        = new Guid("00000000-0000-0000-0000-000000000002"),
                    PlayerId  = new Guid("00000000-0000-0000-0000-000000000002"),
                    PartnerId = new Guid("00000000-0000-0000-0000-000000000001")
                },
                new Partner()
                {
                    Id        = new Guid("00000000-0000-0000-0000-000000000003"),
                    PlayerId  = new Guid("00000000-0000-0000-0000-000000000002"),
                    PartnerId = new Guid("00000000-0000-0000-0000-000000000003")
                },
                new Partner()
                {
                    Id        = new Guid("00000000-0000-0000-0000-000000000004"),
                    PlayerId  = new Guid("00000000-0000-0000-0000-000000000002"),
                    PartnerId = new Guid("00000000-0000-0000-0000-000000000004")
                },
                new Partner()
                {
                    Id        = new Guid("00000000-0000-0000-0000-000000000005"),
                    PlayerId  = new Guid("00000000-0000-0000-0000-000000000003"),
                    PartnerId = new Guid("00000000-0000-0000-0000-000000000001")
                }
            }.AsQueryable();

            _context.Players.AddRange(players);
            _context.Partners.AddRange(partners);
            _context.SaveChanges();
            _sut = new PartnerAccessLayer(_context);
        }
Exemplo n.º 7
0
 public CourseAccessLayer(GolfDbContext context)
 {
     _context = context;
 }
Exemplo n.º 8
0
 public PlayerAccessLayer(GolfDbContext context, ApplicationDbContext userContext)
 {
     _context     = context;
     _userContext = userContext;
 }
Exemplo n.º 9
0
 public PartnerAccessLayer(GolfDbContext context)
 {
     _context = context;
 }
Exemplo n.º 10
0
 public GolfRoundAccessLayer(GolfDbContext context)
 {
     _context = context;
 }
Exemplo n.º 11
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IAntiforgery antiforgery, GolfDbContext golfDbContext)
        {
            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }
            //Seed database with Course data
            golfDbContext.EnsureSeedDataForContext();

            app.UseAuthentication();
            app.UseStaticFiles();
            app.UseSpaStaticFiles();
            //This line enables the app to use Swagger, with the configuration in the ConfigureServices method.
            app.UseSwagger();

            //This line enables Swagger UI, which provides us with a nice, simple UI with which we can view our API calls.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "The Weekend Golfer v1");
            });

            app.Use(next => context =>
            {
                //if (context.Request.Path == "/")
                {
                    //send the request token as a JavaScript-readable cookie, and Angular will use it by default
                    var tokens = antiforgery.GetAndStoreTokens(context);
                    context.Response.Cookies.Append("XSRF-TOKEN", tokens.RequestToken, new CookieOptions
                    {
                        HttpOnly = false,
                        Secure   = true
                    });
                }
                return(next(context));
            });
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action=Index}/{id?}");
            });

            app.UseSpa(spa =>
            {
                // To learn more about options for serving an Angular SPA from ASP.NET Core,
                // see https://go.microsoft.com/fwlink/?linkid=864501

                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseAngularCliServer(npmScript: "start");
                }
            });
        }
Exemplo n.º 12
0
 public RepoProvider(GolfDbContext context)
 {
     _context = context;
 }
Exemplo n.º 13
0
 public RepoProvider()
 {
     _context = new GolfDbContext();
 }
Exemplo n.º 14
0
 public ScoreAccessLayer(GolfDbContext context)
 {
     _context = context;
 }
Exemplo n.º 15
0
        public void Setup()
        {
            var options = new DbContextOptionsBuilder <GolfDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            _context   = new GolfDbContext(options);
            _createdAt = DateTime.Now;
            var courses = new List <Course>()
            {
                new Course()
                {
                    Id            = new Guid("00000000-0000-0000-0000-000000000001"),
                    Name          = "Wembley Golf Course",
                    Created       = _createdAt,
                    Holes         = "18",
                    Location      = "Western Australia",
                    Par           = 72,
                    ScratchRating = 70,
                    Slope         = 120,
                    TeeName       = "Blue Men"
                },
                new Course()
                {
                    Id            = new Guid("00000000-0000-0000-0000-000000000002"),
                    Name          = "Point Walter",
                    Created       = _createdAt,
                    Holes         = "1-9",
                    Location      = "Western Australia",
                    Par           = 35,
                    ScratchRating = 34,
                    Slope         = 115,
                    TeeName       = "Blue Men"
                },
                new Course()
                {
                    Id            = new Guid("00000000-0000-0000-0000-000000000003"),
                    Name          = "Point Walter",
                    Created       = _createdAt,
                    Holes         = "18",
                    Location      = "Western Australia",
                    Par           = 35,
                    ScratchRating = 34,
                    Slope         = 115,
                    TeeName       = "Blue Men"
                },
                new Course()
                {
                    Id            = new Guid("00000000-0000-0000-0000-000000000004"),
                    Name          = "Point Walter",
                    Created       = _createdAt,
                    Holes         = "1-9",
                    Location      = "Western Australia",
                    Par           = 35,
                    ScratchRating = 34,
                    Slope         = 117,
                    TeeName       = "Red Women"
                }
            }.AsQueryable();

            _context.Courses.AddRange(courses);
            _context.SaveChanges();
            _sut = new CourseAccessLayer(_context);
        }
Exemplo n.º 16
0
 public HandicapAccessLayer(GolfDbContext context)
 {
     _context = context;
 }