采用领域驱动的设计模式搭建的开发框架,使用了更加高性能的orm,提升了数据访问的性能。增加了依赖注入,降低应用程序的耦合度。- namespace SharpStrc.Web.Areas.Admin.Conrtollers
- {
- using System.Collections.Generic;
- using System.Web.Mvc;
- using Common;
- using Common.Queries;
- using Domain;
- using Framework.Extensions;
- using Framework.Utilities;
- using Tasks.Commands.Examples;
-
- public class ExampleController : Controller
- {
- public IExampleQuery ExampleQuery { get; set; }
- public ICommandProcessor CommandProcessor { get; set; }
-
- public ActionResult Query()
- {
- List<string> data = ExampleQuery.GetQueries();
-
- return View(data);
- }
-
- public ActionResult Add()
- {
- return View();
- }
-
- [HttpPost]
- public ActionResult Add(ExampleModel example)
- {
- IList<string> messages = new List<string>();
-
- Try.CatchBiz(() =>
- {
- var command = new AddExampleCommand(example.Field);
-
- CommandProcessor.Process(command);
- },
- bex => { messages = bex.ErrorMessages; },
- ex => messages.Add("异常错误。"));
-
- if (messages.Count == 0)
- {
- return Json(new {result = true});
- }
- return Json(new {result = false, message = messages.ToHtml()});
- }
- }
- }
复制代码
|
|