public async Task <AddCategoryResponse> Handle(AddCategoryRequest request, CancellationToken cancellationToken) { try { var newCategory = new DreamCategory { CategoryName = request.CategoryName, DefaultSteps = request.DefaultSteps.Select(ds => new DreamCategoryDefaultStep { IsSponsorRelated = ds.IsSponsorRelated, StepDescription = ds.StepDescription }).ToList() }; await _databaseContext.DreamCategories.AddAsync(newCategory); await _databaseContext.SaveChangesAsync(); return(new AddCategoryResponse { CategoryId = newCategory.DreamCategoryId }); } catch (Exception e) { return(null); } }
private void OnDreamCategoryEdited(CreateEditDreamCategoryPage page, DreamCategoryEditorViewModel model) { DreamCategory original = this.datalayer.GetDreamCategory(model.CategoryId); original.Update(model); this.datalayer.SaveChanges(); this.LoadCategoriesCommand.Execute(null); this.IsBusy = false; }
private void OnDreamCategoryCreated(CreateEditDreamCategoryPage page, DreamCategoryEditorViewModel model) { DreamCategory category = model.Copy <DreamCategory>(); category.CategoryId = 0; if (this.datalayer.AddDreamCategory(category)) { model.CategoryId = category.CategoryId; this.Items.Add(model); } this.IsBusy = false; }
public static IPostprocessComposer <Dream> WithCategory(this IPostprocessComposer <Dream> postProcessComposer, DreamCategory category) { return(postProcessComposer.With(d => d.DreamCategory, category)); }