Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions how-to/buttons-links/transactions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Transactions

Each button is associated with a series of workflows which are defined by chaining the button method with OnClick method. By default these workflows are executed in one transaction scope so in case of any runtime error all the previous steps can be rolled back. In some scenarios executing all the steps in the workflow is not desirable for example when we are registering a new user and we need to send an email to the user in order to confirm the user's email address. We need to send the confirmation email after successful storage of the user’s information and we don’t want the record deletion in case of email dispatch failure, therefore we must instruct M# to execute each of the workflow’s steps on different scope, to do so we use RunInTransaction(false) method.
Each button is associated with a series of workflows which are defined by chaining the button method with OnClick method. By default these workflows are executed in one transaction scope so in case of any runtime error all the previous steps can be rolled back. In some scenarios executing all the steps in the workflow is not desirable for example when we are registering a new user and we need to send an email to the user in order to confirm the user's email address. We need to send the confirmation email after successful storage of the user’s information and we don’t want the record deletion in case of email dispatch failure, therefore we must instruct M# to execute each of the workflow’s steps on different scope, to do so we use `RunInTransaction(false)` method.

```csharp

Expand Down Expand Up @@ -28,14 +28,14 @@ namespace Modules
Button("Cancel").OnClick(x => x.ReturnToPreviousPage());

Button("Save").IsDefault().Icon(FA.Check)
.OnClick(x =>
{
x.RunInTransaction(false);
x.SaveInDatabase();
x.CSharp("info.Item.SendConfirmation();");
x.Display("Saved successfully.")
.DisplayOnModule();
});
.OnClick(x =>
{
x.RunInTransaction(false);
x.SaveInDatabase();
x.CSharp("info.Item.SendConfirmation();");
x.Display("Saved successfully.")
DisplayOnModule();
});
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions how-to/buttons-links/trigering-skipping-validation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Trigering/skipping validation

When working on M# form modules sometimes we need to allow the user to complete the form partially or without accurate input, for example when developing the form and we just need some dummy data for testing purposes. In order to instruct M# To lift any validations’ defined on the entity we should chain the Button method with the CauseValidation and enter false for its first argument.
When working on M# form modules sometimes we need to allow the user to complete the form partially or without accurate input, for example when developing the form and we just need some dummy data for testing purposes. In order to instruct M# to lift any validations’ defined on the entity we should chain the Button method with the `CauseValidation` and enter false for its first argument.



Expand All @@ -21,15 +21,15 @@ namespace Modules
Button("Cancel").OnClick(x => x.ReturnToPreviousPage());

Button("Save")
.IsDefault()
.Icon(FA.Check)
.CausesValidation(false)
.OnClick(x =>
{
x.SaveInDatabase();
x.GentleMessage("Saved successfully.");
x.Go<Admin.CategoriesPage>();
});
.IsDefault()
.Icon(FA.Check)
.CausesValidation(false)
.OnClick(x =>
{
x.SaveInDatabase();
x.GentleMessage("Saved successfully.");
x.Go<Admin.CategoriesPage>();
});
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion how-to/list-modules/exportToCsvExcel.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ If you wish you can change the file name to something more appropriate using Com

```

On clicking this button the User will download file “My Contacts”, this will be an excel or csv file with all the data and layout of the list visible in the browser window, including any active search filters.
By clicking on this button the User will download file “My Contacts”, this will be an excel or csv file with all the data and layout of the list visible in the browser window, including any active search filters.
6 changes: 3 additions & 3 deletions how-to/list-modules/manualSorting.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ To do this, add a method GetSiblings() to the Domain Logic for your Entity.

This method must:

- be called GetSiblings
- be public
- return a Task which returns an Enumerable of your Entity
- Be called GetSiblings
- Be public
- Return a Task which returns an Enumerable of your Entity

If this method exists MSharp will automatically use it to only apply unique order to siblings.

Expand Down
2 changes: 1 addition & 1 deletion how-to/list-modules/sorting.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ In this example, Products are sorted by Category in reverse alphabetical order a
This causes the following code to be generated in the GetSource method of the controller

```csharp
result = result.OrderByDescending(item => item.Wearer)
result = result.OrderByDescending(item => item.Category)
.ThenBy(item => item.WeightInKg);
```
12 changes: 6 additions & 6 deletions how-to/menus/creatingMenu.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ namespace Modules

There are many methods which can be applied to the menu, here extra CSS classes have been added for styling.

Useful Methods for Items include:
Useful methods for items include:

- OnClick(): Determines the destination of the link
- `OnClick()`: Determines the destination of the link

- VisibleIf() : especially useful with AppRole allowing for a different user experience depending on the role of the User.
- `VisibleIf()`: Especially useful with AppRole allowing for a different user experience depending on the role of the User.

- Icon(FA icon) or Icon(string value): to add an icon to the button, M# natively supports Font Awesome.
- `Icon(FA icon)` or `Icon(string value)`: to add an icon to the button, M# natively supports Font Awesome.

Once created the Menu can be Set() on any Pages you want, the use of root pages is very useful in this endeavour.
Once created, the Menu can be `Set()` on any pages you want, the use of root pages is very useful in this endeavour.

```csharp

Expand All @@ -67,4 +67,4 @@ Once created the Menu can be Set() on any Pages you want, the use of root pages

```

PageSettings include TopMenu, LeftMenu and SubMenu which provide simple styling as standard but you can add your own if you fancy a challenge.
`PageSettings` include `TopMenu`, `LeftMenu` and `SubMenu` which provide simple styling as standard but you can add your own if you fancy a challenge.
19 changes: 9 additions & 10 deletions how-to/menus/dynamicMenuItems.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ For example, separate menu links go to pages that display foods which satisfy di
```

- Create a new item for your menu and give it a Name.
- By specifying the DataSourceType() as DietType, the menu is populated with one link for every Diet Type in the database. If you do not want every instance to be used you can specify a DataSource() instead.
- By specifying the `DataSourceType()` as DietType, the menu is populated with one link for every Diet Type in the database. If you do not want every instance to be used you can specify a `DataSource()` instead.
- The text of the menu link will need to be written dynamically using `c#:`
- Key is used to give each dynamically created menu link a unique identifier, which is necessary for menu item highlighting to work.
- When you navigate using this item you must Send() the `item.ID` so you are able to generate the appropriate content on the destination page.
- `Key` is used to give each dynamically created menu link a unique identifier, which is necessary for menu item highlighting to work.
- When you navigate using this item you must `Send()` the `item.ID` so you are able to generate the appropriate content on the destination page.

### Custom Menu Item Highlighting

MSharp's menu item highlighting is performed automatically by matching the urls with the menu item's link, however when using dynamic menu items you will need to add an extra rule based on the key as they all link to the same page.
Add a SpecialSelectedKeyRule() to the Menu above its items.
Add a `SpecialSelectedKeyRule()` to the Menu above its items.

```csharp
SpecialSelectedKeyRule("if(Request.Has(\"category\")) return Request.Query[\"category\"];");
```

This checks to see whether a query string "category" has been passed and if it has, it uses this categories value to determine what menu items Key it corresponds to.
This checks to see whether a query string "category" has been passed and if it has, it uses this category value to determine what menu items `Key` it corresponds to.

### In the destination Module:

Expand All @@ -42,8 +42,7 @@ This checks to see whether a query string "category" has been passed and if it h
{
HeaderText("c#: info.Category == null ? \"Food\" : info.Category.Name")
.SourceCriteria("info.Category == item.Category")
.SourceEvaluationCriteria("info.Category!=null");

.SourceEvaluationCriteria("info.Category != null");

ViewModelProperty("DietType", "Category")
.FromRequestParam("category");
Expand All @@ -54,8 +53,8 @@ This checks to see whether a query string "category" has been passed and if it h
}
```

- Create a new ViewModelProperty “Category” of type “DietType” from the query string “category”.
- Create a new `ViewModelProperty` “Category” of type “DietType” from the query string “category”.
- The header text can be made dynamic to match the menu item. Here, there is a general heading for if there is no query string received.
- The date source can be filtered using SourceCriteria(). Only items whose category matches the view model property Category will be shown.
- To avoid exceptions in the event that there is no category received, use SourceEvaluationCriteria(). If there is no info.Category then it skips SourceCriteria() and displays all results.
- The date source can be filtered using `SourceCriteria()`. Only items whose category matches the view model property Category will be shown.
- To avoid exceptions in the event that there is no category received, use `SourceEvaluationCriteria()`. If there is no `info.Category` then it skips `SourceCriteria()` and displays all results.

14 changes: 7 additions & 7 deletions how-to/navigation/modal-PopUp.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ContactsList()
}
```

3) When Navigating away from the pop up, make sure the Modal is closed instead of being redirected
3) When navigating away from the pop up, make sure the Modal is closed instead of being redirected

```csharp
public ContactForm()
Expand All @@ -54,12 +54,12 @@ public ContactForm()
.OnClick(x => x.CloseModal());

Button("Save").IsDefault().Icon(FA.Check)
.OnClick(x =>
{
x.SaveInDatabase();
x.GentleMessage("Saved successfully.");
x.CloseModal(Refresh.Ajax);
});
.OnClick(x =>
{
x.SaveInDatabase();
x.GentleMessage("Saved successfully.");
x.CloseModal(Refresh.Ajax);
});
}
```

Expand Down
2 changes: 1 addition & 1 deletion how-to/search/customSearchElement.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace ViewModel
}
```

- `MemoryFilterCode()` - Insert the code to control the search functionality. Use info. to refer to the filter properties generated above. This code is also generated in the Controller, in the GetSource() method:
- `MemoryFilterCode()` - Insert the code to control the search functionality. Use `info.` to refer to the filter properties generated above. This code is also generated in the Controller, in the `GetSource()` method:

```csharp
async Task<IEnumerable<Gadget>> GetSource(vm.GadgetsList info)
Expand Down
6 changes: 3 additions & 3 deletions how-to/uiComposition/viewComponents.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ When you add a module to multiple pages MSharp removes the module’s code from
}
```

Now Msharp will generate all the necessary controllers and bindings without it needing to be explicitly added to a page in the UI. ViewComponent controllers are generated in Website>Views>Modules>Components.
Now MSharp will generate all the necessary controllers and bindings without it needing to be explicitly added to a page in the UI. ViewComponent controllers are generated in Website > Views > Modules > Components.

Now it can instead be invoked from a Layout page or from inside Markup.

```csharp
<footer>@await Component.InvokeAsync(typeof(Footer))</footer>
```
View Components are particularly suited to
- Dynamic Menus
- Login Panels
- Dynamic menus
- Login panels
- Shopping carts
8 changes: 4 additions & 4 deletions how-to/uiComposition/visibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ This allows for more dynamic content and less repetition of code.

Visibility can be changed on a variety of elements, including columns, buttons, menu items and whole modules.

VisibleIf() can be invoked by writing the desired code in a string, this code is then generated in the Cshtml file.
`VisibleIf()` can be invoked by writing the desired code in a string, this code is then generated in the Cshtml file.

Often you want to limit visibility based on the Users role, in this case you can invoke VisibleIf() using AppRole.
Often you want to limit visibility based on the Users role, in this case you can invoke `VisibleIf()` using `AppRole`.

## Examples

Expand All @@ -24,7 +24,7 @@ If a Contacts List is filtered by query string “category” the Category colum
Column(x => x.Category).VisibleIf("info.Category == null");
```

To only effect the visibility of certain cells in a column, depending on item, use CellVisibleIf().
To only effect the visibility of certain cells in a column, depending on item, use `CellVisibleIf()`.

### Using AppRole

Expand All @@ -50,4 +50,4 @@ Only Admin Users can view the button column, a button should only be visible if
.OnClick(x => x.Go<ContactsPage>().Send("item", "item.ID"));
```

On a button column VisibleIf() affects the visibility of the individual buttons, so to hide the column use ColumnVisibleIf().
On a button column `VisibleIf()` affects the visibility of the individual buttons, so to hide the column use `ColumnVisibleIf()`.