コード例 #1
0
        public void OnTimelineUpdate()
        {
            Paused      = true;
            CurrentTime = 0;

            TimelineUpdate?.Invoke(this, EventArgs.Empty);
        }
コード例 #2
0
ファイル: ChirpsController.cs プロジェクト: enadzan/chirper
        public IActionResult Post(DtoChirpPost dto)
        {
            _db.BeginTransaction();

            var chirp = new Chirp
            {
                UserId       = int.Parse(User.Identity.Name ?? "1"),
                ChirpTimeUtc = DateTime.UtcNow,
                ChirpType    = ChirpType.Chirp,
                Contents     = dto.Contents
            };

            _db.Chirps.Add(chirp);

            _db.SaveChanges();

            // Publish chirp processing job, before commit.
            // If the publishing fails, the transaction will be rolled back.
            //
            // We're using the job publish as the last committing resource because
            // it does not participate in the DB transaction.

            JobBatch.Do(() =>
            {
                TimelineUpdate.Publish(new TimelineUpdateArgs
                {
                    ChirpId  = chirp.Id,
                    AuthorId = chirp.UserId,
                    TimeUtc  = chirp.ChirpTimeUtc
                });

                HashTagUpdate.Publish(chirp.Id);
            });

            _db.CommitTransaction();

            return(Ok(chirp.Id));
        }