Ejemplo n.º 1
0
        static async Task Step1()
        {
            const string streamName = Globals.StreamName;

            var conn = await Connection.CreateConnection();

            var step1EventData = UserProjections.ReadEvents(Globals.FilePath);
            var eventData      = step1EventData.ToArray();

            await conn.AppendToStreamAsync(streamName, ExpectedVersion.Any, eventData);

            Console.WriteLine($"Published {step1EventData.Count} events to '{Globals.StreamName}'");
        }
Ejemplo n.º 2
0
        static async Task Main(string[] args)
        {
            try
            {
                var task = args[0] switch
                {
                    "step1" => Step1(),
                    "step2" => Step2(),
                    "step2subs" => Step2Subs(),
                    "step3" => UserProjections.Step3(Globals.AdminCredentials),
                    "step3update" => UserProjections.Step3Update(Globals.AdminCredentials),
                    "step3options" => UserProjections.Step3ProjectionOptions(Globals.AdminCredentials),
                    _ => Console.Out.WriteLineAsync("Unknown option")
                };
                await task;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.GetBaseException().Message);
            }

            Console.WriteLine("Press enter to exit");
            Console.ReadLine();
        }
Ejemplo n.º 3
0
        public async Task <bool> BookTicket(int projectionId, string userId)
        {
            var projectionInfo = await this.GetProjectionInfo(projectionId, userId);

            if (projectionInfo == null ||
                projectionInfo.Date < DateTime.UtcNow ||
                projectionInfo.UserHasATicket ||
                projectionInfo.VisitorsCount >= 50)
            {
                return(false);
            }

            var ticket = new UserProjections
            {
                ProjectionId = projectionId,
                VisitorId    = userId
            };

            this.db.Add(ticket);

            await this.db.SaveChangesAsync();

            return(true);
        }