public async Task <TextItemIdentity> New() { var textItemIdentity = TextItemIdentity.New(); await this.ExecuteInContextAsync(async dbContext => { var textItemEntity = new Entities.TextItem() { GUID = textItemIdentity.Value, }; dbContext.Add(textItemEntity); await dbContext.SaveChangesAsync(); }); return(textItemIdentity); }
public async Task <TextItemIdentity> New(TextItemTypeIdentity typeIdentity, string value) { var textItemIdentity = TextItemIdentity.New(); await this.ExecuteInContextAsync(async dbContext => { var textItemTypeID = await dbContext.TextItemTypes.Where(x => x.GUID == typeIdentity.Value).Select(x => x.ID).SingleAsync(); var entity = new Entities.TextItem() { GUID = textItemIdentity.Value, TextItemTypeID = textItemTypeID, Value = value, }; return(entity); }); return(textItemIdentity); }
public async Task <TextItemIdentity> Add(TextItem textItem) { var textItemIdentity = TextItemIdentity.New(); await this.ExecuteInContextAsync(async dbContext => { var textItemTypeID = await dbContext.TextItemTypes.Where(x => x.GUID == textItem.Type.Identity.Value).Select(x => x.ID).SingleAsync(); var entity = new Entities.TextItem() { GUID = textItemIdentity.Value, TextItemTypeID = textItemTypeID, Value = textItem.Value, }; dbContext.TextItems.Add(entity); await dbContext.SaveChangesAsync(); }); return(textItemIdentity); }