A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© aisini 金牌黑马   /  2014-7-28 18:50  /  874 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

                采用领域驱动的设计模式搭建的开发框架,使用了更加高性能的orm,提升了数据访问的性能。增加了依赖注入,降低应用程序的耦合度。
  1. namespace SharpStrc.Web.Areas.Admin.Conrtollers
  2. {
  3.     using System.Collections.Generic;
  4.     using System.Web.Mvc;
  5.     using Common;
  6.     using Common.Queries;
  7.     using Domain;
  8.     using Framework.Extensions;
  9.     using Framework.Utilities;
  10.     using Tasks.Commands.Examples;

  11.     public class ExampleController : Controller
  12.     {
  13.         public IExampleQuery ExampleQuery { get; set; }
  14.         public ICommandProcessor CommandProcessor { get; set; }

  15.         public ActionResult Query()
  16.         {
  17.             List<string> data = ExampleQuery.GetQueries();

  18.             return View(data);
  19.         }

  20.         public ActionResult Add()
  21.         {
  22.             return View();
  23.         }

  24.         [HttpPost]
  25.         public ActionResult Add(ExampleModel example)
  26.         {
  27.             IList<string> messages = new List<string>();

  28.             Try.CatchBiz(() =>
  29.                 {
  30.                     var command = new AddExampleCommand(example.Field);

  31.                     CommandProcessor.Process(command);
  32.                 },
  33.                          bex => { messages = bex.ErrorMessages; },
  34.                          ex => messages.Add("异常错误。"));

  35.             if (messages.Count == 0)
  36.             {
  37.                 return Json(new {result = true});
  38.             }
  39.             return Json(new {result = false, message = messages.ToHtml()});
  40.         }
  41.     }
  42. }
复制代码


0 个回复

您需要登录后才可以回帖 登录 | 加入黑马