public Result<Category> CreateCategory(CreateCategoryCommand newCategoryCommand) { return Result<Category>.SafeExecute<CategoryService>(result => { using (DataContext = new RmmDataContext(RmmDataContext.CONNECTIONSTRING)) { var newCategoryEntity = new Category() { Balance = 0, Color = newCategoryCommand.Color, CreatedDate = DateTime.Now, Name = newCategoryCommand.Name }; DataContext.Category.Log().InsertOnSubmit(newCategoryEntity); DataContext.SubmitChanges(); var AddedCategory = DataContext.Category.Log().Where(a => a.CreatedDate == newCategoryEntity.CreatedDate).First(); result.Value = AddedCategory; } }, () => "error"); }
void HandleCreateTaskSelected() { var newCategoryCommand = new CreateCategoryCommand() { Name = Category.Name, Color = Category.Color }; CategoryService.CreateCategory(newCategoryCommand); NavigateTo("/MainPage.xaml?update=category", null); Dispose(); }