Example #1
0
        public ArticleEventItem(ArticleEvent item)
        {
            ServerId       = item.ServerId;
            Id             = item.Id;
            Title          = item.Title;
            TitlePhoto     = item.TitlePhoto;
            Photo          = item.Photo;
            Description    = item.Description;
            Text           = item.Text;
            AuthorId       = item.AuthorId;
            EditorId       = item.EditorId;
            AddedDate      = item.AddedDate;
            PublishedDate  = item.PublishedDate;
            MarkerId       = item.MarkerId;
            StartDate      = item.StartDate;
            StopDate       = item.StopDate;
            StartTime      = item.StartTime;
            Adress         = item.Adress;
            StatusId       = item.StatusId;
            BaseCategoryId = item.BaseCategoryId;
            IsFavorite     = item.IsFavorite;
            AuthorName     = new AuthorName
            {
                FirstName  = item.FirstName,
                MiddleName = item.MiddleName,
                LastName   = item.LastName
            };
            Tags        = item.TagsString.Split(',').Where(s => s != "");
            SourceUrl   = item.SourceUrl;
            SourcePhoto = item.SourcePhoto;

            AddressName = item.AddressName;
        }
Example #2
0
        public int SaveArticleEvent(ArticleEventItem item)
        {
            var dbItem = new ArticleEvent(item)
            {
                OwnerServerId = ApplicationSettings.CurrentUser.Guid
            };

            if (
                ArticlesEvents.Any(
                    i => i.OwnerServerId == ApplicationSettings.CurrentUser.Guid && i.ServerId == item.ServerId))
            {
                _db.Update(dbItem);
                return(item.Id);
            }
            else
            {
                var a = _db.Insert(dbItem);
                return(a);
            }
            //if (dbItem.Id == 0)
            //{
            //    var a = _db.Insert(dbItem);
            //    return a;
            //}

            //_db.Update(dbItem);
            //return item.Id;
        }
Example #3
0
        public async Task DispatchShouldDispatchEvents()
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddTransient <IEventHandler <ArticleEvent>, ArticleEventHandler>();

            var dispatcher = new EventDispatcherService(serviceCollection.BuildServiceProvider());

            var domainEvent = new ArticleEvent();

            await dispatcher.Dispatch(domainEvent);

            Assert.True(domainEvent.Handled);
        }