예제 #1
0
        public virtual async Task <int> AddAsync(TblPostDescriptions record)
        {
            _dbContext.PostDescriptions.Add(record);
            await _dbContext.SaveChangesAsync();

            QueryCacheManager.ExpireTag(CacheTags.PostDescription);

            _eventPublisher.EntityInserted(record);

            return(record.Id);
        }
예제 #2
0
        public virtual async Task UpdateAsync(TblPostDescriptions record)
        {
            var oldRecord = await FindByIdAsync(record.Id);

            _dbContext.PostDescriptions.AddOrUpdate(record);
            await _dbContext.SaveChangesAsync();

            QueryCacheManager.ExpireTag(CacheTags.PostDescription);

            _eventPublisher.EntityUpdated(record, oldRecord);
        }
예제 #3
0
        public virtual async Task <PostDescriptionModel> PreparePostDescriptionModelAsync(TblPostDescriptions description, int postId)
        {
            PostDescriptionModel result;

            if (description == null)
            {
                result = new PostDescriptionModel();
            }
            else
            {
                result = description.Adapt <PostDescriptionModel>();
                await description.LoadAllLocalizedStringsToModelAsync(result);
            }

            result.PostId = postId;
            return(result);
        }