示例#1
0
        public virtual async Task <int> AddAsync(TblPostAttributesMapping record)
        {
            _dbContext.PostAttributesMapping.Add(record);
            await _dbContext.SaveChangesAsync();

            QueryCacheManager.ExpireTag(CacheTags.PostAttribute);

            _eventPublisher.EntityInserted(record);

            return(record.Id);
        }
示例#2
0
        public virtual async Task UpdateAsync(TblPostAttributesMapping record)
        {
            var oldRecord = await FindByIdAsync(record.Id);

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

            QueryCacheManager.ExpireTag(CacheTags.PostAttribute);

            _eventPublisher.EntityUpdated(record, oldRecord);
        }
        public virtual async Task <PostAttributeMappingModel> PreparePostAttributeMappingModelAsync(TblPostAttributesMapping attribute, int postId)
        {
            PostAttributeMappingModel result;

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

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