Web Controller |
SOWI Web Controller Template creates a web controller of model MVC with
SOWI App as business logical
SOWI Data as data model
This topic contains the following sections:
The web project based on SOWI Web Project
The SOWI App which presents the business logic must be available.
The SOWI Data which presents the data model must be available.
The SOWI Template package must be installed
Check following references (normally already specified):
SOWIData, SOWIData.Helper,
SOWIWeb.Helper, SOWIWeb.Foundation and
SOWIApp.Foundation
Check exist the SOWI Configuration (file: SOWIApp.sconfig) into folder App_Data
Choose or create a new SOWI Web project into Solution Explorer
Expand his items and select the Controllers folder
Add SOWI Web Controller via template
Call context menu and choose menu item Add, New Item...
The dialog Add New Item appears
Choose Installed, Visual C# and SOWIWebController.Template
Edit the web controller name into textbox Name e.g. TestUser (without suffix Controller)
Push button Add
The dialog SOWI Web Controller appears
Choose the App Class into the class list
Choose the Data Item Class into the class list
Push button OK
Now the following item is created:
SOWI Web controller based SOWIWeb.HelperControllerStandardDataItemClass into folder Controllers
SOWI Web View into folder Views subfolder the name of controller
Create.cshtml
Delete.cshtml
Details.cshtml
Edit.cshtml
Index.cshtml
The elements contain all standard functions and are therefore executable.
Note |
---|
The code may vary depending on your choice options and version. |
1using SOWIData.Helper; 2using System; 3 4namespace SOWIWeb.Foundation.TestWeb.Controllers 5{ 6 /// <summary> 7 /// Web controller 8 /// </summary> 9 public class TestUserController : SOWIWeb.Helper.ControllerStandard<SOWIData.Management.User> 10 { 11 #region --- AppModule --- 12 13 /// <summary> 14 /// Temporary App object for better performance 15 /// </summary> 16 private SOWIApp.Administrator.User _AppUser; 17 18 /// <summary> 19 /// Give a App object with full function (SOWIApp.Administrator.User) 20 /// </summary> 21 private SOWIApp.Administrator.User AppUser 22 { 23 get 24 { 25 if (SOWIWeb.Helper.Session.IsAuthenticated) 26 { 27 if (_AppUser == null) 28 { 29 _AppUser = new SOWIApp.Administrator.User(SOWIWeb.Helper.Session.Token.ToGUID()); 30 } 31 return _AppUser; 32 } 33 return null; 34 } 35 } 36 37 /// <summary> 38 /// Give a App object with standard function (see <see cref="SOWIApp.Foundation.IAppController{DataItemClass}"/>) 39 /// </summary> 40 protected override SOWIApp.Foundation.IAppController<SOWIData.Management.User> AppModule 41 { get { return (SOWIApp.Foundation.IAppController<SOWIData.Management.User>)this.AppUser; } } 42 43 #endregion 44 45 /// <summary> 46 /// Gives a new data item of type <see cref="SOWIData.Management.User"/> 47 /// </summary> 48 protected override SOWIData.Management.User GetNewDataItem { get { return new SOWIData.Management.User(); } } 49 50 } 51}
1@* 2 View: /TestUser/Create/ 3*@ 4 5@model SOWIData.Management.User 6 7@Html.Partial("~/Views/Form/Form.cshtml")
1@* 2 View: /TestUser/Delete/ 3*@ 4 5@model SOWIData.Management.User 6 7@Html.Partial("~/Views/Form/Form.cshtml")
1@* 2 View: /TestUser/Details/ 3*@ 4 5@model SOWIData.Management.User 6 7@Html.Partial("~/Views/Form/Form.cshtml")
1@* 2 View: /TestUser/Edit/ 3*@ 4 5@model SOWIData.Management.User 6 7@Html.Partial("~/Views/Form/Form.cshtml")
1@* 2 View: /TestUser/Index/ 3*@ 4 5@*@model IEnumerable<SOWIData.Management.User>*@ 6@model IEnumerable<object> 7 8@Html.Partial("~/Views/Form/Form.cshtml")