Exemplo n.º 1
0
        public ActionResult Add(DiaryItemDto item)
        {
            // 发布CreateItemCommand到CommandBus中
            ServiceLocator.CommandBus.Send(new CreateItemCommand(Guid.NewGuid(), item.Title, item.Description, -1, item.From, item.To));

            return RedirectToAction("Index");
        }
Exemplo n.º 2
0
 public ActionResult Edit(Guid id)
 {
     var item = ServiceLocator.QueryStorage.GetById(id);
     var model = new DiaryItemDto()
     {
         Description = item.Description,
         From = item.From,
         Id = item.Id,
         Title = item.Title,
         To = item.To,
         Version = item.Version
     };
     return View(model);
 }
Exemplo n.º 3
0
        public ActionResult Edit(DiaryItemDto item)
        {
            try
            {
                ServiceLocator.CommandBus.Send(new ChangeItemCommand(item.Id, item.Title, item.Description, item.From, item.To, item.Version));
            }
            catch (ConcurrencyException err)
            {

                ViewBag.error = err.Message;
                ModelState.AddModelError("", err.Message);
                return View();

            }

            return RedirectToAction("Index");
        }
Exemplo n.º 4
0
 public void Add(DiaryItemDto item)
 {
     Items.Add(item);
 }