Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
 public static IPostprocessComposer <Dream> WithCategory(this IPostprocessComposer <Dream> postProcessComposer, DreamCategory category)
 {
     return(postProcessComposer.With(d => d.DreamCategory, category));
 }