示例#1
0
文件: AddCommand.cs 项目: nelly2k/one
        public async Task <TId> Add <TSource, TEntity, TId>(TSource source, Func <TEntity, TId> getId)
            where TEntity : Entity
        {
            var entity = mapper.Map <TEntity>(source);

            entity.CreatedDate = dateTimeService.Now;
            entity.UpdatedDate = dateTimeService.Now;

            oneContext.Add(entity);
            await oneContext.SaveChangesAsync();

            return(getId(entity));
        }
示例#2
0
        public async Task Execute(Guid id0, int id1)
        {
            var feature = await oneContext.Features.SingleAsync(x => x.StoryId == id0 && x.Id == id1);

            oneContext.Remove(feature);
            await oneContext.SaveChangesAsync();
        }
示例#3
0
        public async Task Execute(Guid id)
        {
            var story = await context.Stories.SingleAsync(x => x.Id == id);

            context.Remove(story);
            await context.SaveChangesAsync();
        }
示例#4
0
        public async Task Execute(Guid id0, int id1)
        {
            var option = await oneContext.Options.SingleAsync(x => x.StoryId == id0 &&
                                                              x.Id == id1);

            oneContext.Remove(option);
            await oneContext.SaveChangesAsync();
        }
示例#5
0
        public async Task Execute(Guid id0, int id1, int id2, int id3)
        {
            var optionValue = await oneContext.OptionValues
                              .SingleAsync(x => x.StoryId == id0 &&
                                           x.FeatureId == id1 &&
                                           x.OptionId == id2 &&
                                           x.OptionValueType.Equals(id3));

            oneContext.Remove(optionValue);
            await oneContext.SaveChangesAsync();
        }
示例#6
0
        public async Task UpdateEntity <T>(Func <OneContext, Task <T> > getAction, string field, object value)
            where T : Entity
        {
            var entity = await getAction(oneContext);

            var propertyInfo = GetProperty <T>(field);

            SetValue(propertyInfo, entity, value);

            await oneContext.SaveChangesAsync();
        }
示例#7
0
        public async Task <Guid> Execute(NewStory model)
        {
            var story = mapper.Map <NewStory, Story>(model);

            story.CreatedDate = dateTimeService.Now;
            story.UpdatedDate = dateTimeService.Now;

            context.Add(story);

            await context.SaveChangesAsync();

            return(story.Id);
        }
示例#8
0
        public async Task <int> Execute(NewOption model)
        {
            var option = new Option
            {
                StoryId = model.StoryId,
                Title   = model.Title
            };

            oneContext.Add(option);

            await oneContext.SaveChangesAsync();

            return(option.Id);
        }