public ActionResult CreatePerson(EditModel m)
        {
            EventDbContext db     = new EventDbContext();
            var            person = db.GetPersons().FirstOrDefault(x => x.EventId == m.SelectedEventId && x.Id == m.Person.Id);

            if (person == null)
            {
                var newPerson = new Person {
                    FirstName       = m.Person.FirstName,
                    LastName        = m.Person.LastName,
                    PersonalCode    = m.Person.PersonalCode,
                    PaymentMethodId = m.SelectedPaymentMethodId,
                    Info            = m.Person.Info,
                    EventId         = m.SelectedEventId,
                    RegisterDate    = DateTime.Now,
                    Active          = true
                };
                db.Persons.Add(newPerson);
                db.SaveChanges();
            }
            else
            {
                var dbPerson = db.Persons.FirstOrDefault(x => x.EventId == m.SelectedEventId && x.Id == m.Person.Id);
                dbPerson.FirstName       = m.Person.FirstName;
                dbPerson.LastName        = m.Person.LastName;
                dbPerson.PersonalCode    = m.Person.PersonalCode;
                dbPerson.PaymentMethodId = m.SelectedPaymentMethodId;
                dbPerson.Info            = m.Person.Info;
                UpdateModel(dbPerson);
                db.SaveChanges();
            }
            return(RedirectToAction("Participants", new { id = m.SelectedEventId }));
        }
Example #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.LogDeployDate();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            EventDbContext.UpdateDatabase(app);

            app.UseMvc();

            app.AddMessageHandler <TestEvent, TestHandler>();

            var _firestoreDb = CommonFunctions.InitiFirestore(env);
            var query        = _firestoreDb.Collection(ConstantServices.OrderCollection)
                               //.WhereEqualTo("Status", (int)OrderStatus.New)
                               .WhereEqualTo(ConstantServices.ServiceC, false);
            var eve = new ListenNewOrder {
                ServeName = ConstantServices.ServiceC, CollectionName = ConstantServices.OrderCollection
            };

            app.AddFirestoreHandler <ListenNewOrder, FirestoreHandler>(eve, query);

            app.CheckEventRegistered(typeof(Startup).Namespace);
        }
Example #3
0
 /// <summary>
 /// Constructor for the EventService.
 /// </summary>
 /// <param name="context">A database ApplicationDbContext</param>
 /// <param name="applicationIdentityService">An instance of ApplicationIdentityService to retrieve users.</param>
 public EventService(
     EventDbContext context,
     IApplicationIdentityService applicationIdentityService)
 {
     _dbContext = context ?? throw new ArgumentNullException(nameof(context));
     _applicationIdentityService = applicationIdentityService ?? throw new ArgumentNullException(nameof(applicationIdentityService));
 }
        public static EventDbContext Create()
        {
            var options = new DbContextOptionsBuilder <EventDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var context = new EventDbContext(options);

            context.Speakers.AddRange(
                new Speaker()
            {
                SpeakerId = 1,
                Name      = "Alexander Wiebe",
                Secret    = "Loves Angular"
            },
                new Speaker()
            {
                SpeakerId = 2,
                Name      = "David Crossman",
                Secret    = "Loves Git"
            },
                new Speaker()
            {
                SpeakerId = 3,
                Name      = "Patrick Ullrich",
                Secret    = "Loves .NET Core"
            }
                );

            context.Sessions.AddRange(
                new Domain.Entities.Session()
            {
                SessionId   = 1,
                Title       = "Angular State Management: Beyond NGRX",
                Description = "NGRX is a large opinionated library on how to do state management in Angular and is often marketed as ‘The Solution’ to all your state management woes. This talk is to tell you that NGRX isn’t the panacea to every ailment. On top of not curing my baldness NGRX is not always how to solve state management. There’s lots of other ways to deal with state management in Angular. This talk walks through the life of an Angular app and the appropriate state management tactics at different milestones. One size does not fit all. Of course, an internet bucket of hype has to be based on something, so we’ll finish with ‘when you need NGRX how to get started.",
                SignUps     = 0,
                SpeakerId   = 1
            },
                new Domain.Entities.Session()
            {
                SessionId   = 2,
                Title       = "Demystifying Git - Git Under the Hood",
                Description = "When working within a project using Git, you notice a folder .git with a bunch of files and folders containing all types of information. The technical talk will cover some plumbing and porcelain commands with Git and how it manages your files within the .git folder. We will do a deep dive into how Git store data and how it all comes together to track changes for files and folders.",
                SignUps     = 0,
                SpeakerId   = 2
            },
                new Domain.Entities.Session()
            {
                SessionId   = 3,
                Title       = "Vertical Slice Architecture with .Net Core and MediatR - A Work in Progress",
                Description = "A good architecture should reduce business risk associated to the solution. This is a hard task, especially if requirements can change constantly. Inspired by Jimmy Bogards talk on Vertical Slice Architecture, we will build out a foundation for a project using Dot Net Core 2.2 and MediatR and walk through some real life scenarios to see if the architecture can adapt to any new requirements we are introducing.",
                SignUps     = 0,
                SpeakerId   = 3
            }
                );

            context.SaveChanges();

            return(context);
        }
Example #5
0
 public IndexModel(
     ILogger <IndexModel> logger,
     EventDbContext context)
 {
     _logger  = logger;
     _context = context;
 }
Example #6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, EventDbContext dbContext)
        {
            dbContext.Database.EnsureCreated();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
            });
        }
        public ActionResult DeactivatePerson(int id, int eventId)
        {
            EventDbContext db       = new EventDbContext();
            var            dbPerson = db.Persons.FirstOrDefault(x => x.Id == id && x.EventId == eventId);

            dbPerson.Active = false;
            UpdateModel(dbPerson);
            db.SaveChanges();
            return(RedirectToAction("Participants", new { id = eventId }));
        }
 public IndexModel(
     ILogger <IndexModel> logger,
     EventDbContext context,
     UserManager <MyUser> userManager,
     RoleManager <IdentityRole> roleManager)
 {
     _logger      = logger;
     _context     = context;
     _userManager = userManager;
     _roleManager = roleManager;
 }
        public ActionResult Index()
        {
            var db             = new EventDbContext();
            var events         = db.Events.ToList();
            var paymentMethods = db.PaymentMethods.ToList();

            if (paymentMethods.Count < 1)
            {
                db.AddPaymentMethods();
            }
            return(View(events));
        }
        // Ett alternativt sätt att ta in services
        public async Task OnGetAsync(bool?resetDb,
                                     [FromServices] EventDbContext context,
                                     [FromServices] UserManager <Buyer> userManager,
                                     [FromServices] RoleManager <IdentityRole> roleManager,
                                     [FromServices] SignInManager <Buyer> signInManager)
        {
            if (resetDb ?? false)
            {
                await signInManager.SignOutAsync();

                await context.ResetAndSeedAsync(userManager, roleManager);
            }
        }
Example #11
0
        public CommandHandlerTest()
        {
            var builder = new DbContextOptionsBuilder <EventDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString());
            var context = new EventDbContext(builder.Options);

            IServiceCollection serviceCollection = new ServiceCollection();

            serviceCollection.AddTransient <ICommandDispatcher, CommandDispatcher>();
            serviceCollection.RegisterAggregateFactory <TestAggregate, TestAggregateFactory>();
            serviceCollection.AddTransient <IEventDataFactory <EventData, Guid, Guid>, EventDataFactory>();
            serviceCollection.RegisterCommandHandler <TestCommand, TestCommandHandler>();
            serviceCollection.AddSingleton <EventDbContext <EventData, Guid, Guid> >(context);
            serviceCollection.AddScoped <IEventStore <EventData, Guid, Guid>, EventStore.EventStore>();
            _provider = serviceCollection.BuildServiceProvider();
        }
Example #12
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            EventDbContext.UpdateDatabase(app);

            app.UseMvc();
        }