コード例 #1
0
        public async Task <TagEntity> AddTagAsync(TagEntity tagEntity)
        {
            tagEntity.Url = tagEntity.Name.Unidecode();
            await _newsContext
            .Tags
            .AddAsync(tagEntity);

            await _newsContext.SaveChangesAsync();

            return(tagEntity);
        }
コード例 #2
0
        public async Task <CategoryEntity> AddCategoryAsync(CategoryEntity categoryEntity)
        {
            categoryEntity.Url = categoryEntity.Url.ToLower();
            await _newsContext
            .Categories
            .AddAsync(categoryEntity);

            await _newsContext.SaveChangesAsync();

            return(categoryEntity);
        }
コード例 #3
0
        public async Task <T> AddPostAsync <T>(T map) where T : PostEntity
        {
            map.ModifiedOn  = DateTime.Now;
            map.CreatedOn   = DateTime.Now;
            map.PublishedOn = DateTime.Now; // TODO!
            await _newsContext.Set <T>().AddAsync(map);

            await _newsContext.SaveChangesAsync();

            return(map);
        }