コード例 #1
0
 public async Task <IActionResult> Add([FromForm] Soucast model)
 {
     if (!ModelState.IsValid)
     {
         return(RedirectToAction("Edit"));
     }
     if (model.SoucastId != Guid.Empty)
     {
         var command = new CommandSoucastUpdate()
         {
             Nazev     = model.Nazev,
             ParentId  = model.ParentId,
             SoucastId = model.SoucastId,
             Zkratka   = model.Zkratka
         };
         await client.UpdateAsync(command);
     }
     else
     {
         var command = new CommandSoucastCreate()
         {
             Nazev     = model.Nazev,
             ParentId  = model.ParentId,
             SoucastId = model.SoucastId,
             Zkratka   = model.Zkratka
         };
         await client.AddAsync(command);
     }
     return(RedirectToAction("Index"));
 }
コード例 #2
0
        public async Task <IActionResult> Update([FromForm] Soucast model)
        {
            var command = new CommandSoucastUpdate()
            {
                Nazev     = model.Nazev,
                ParentId  = model.ParentId,
                SoucastId = model.SoucastId,
                Zkratka   = model.Zkratka
            };
            await client.UpdateAsync(command);

            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public async Task Update(CommandSoucastUpdate cmd)
        {
            var item = db.Soucasti.FirstOrDefault(u => u.SoucastId == cmd.SoucastId);

            if (item != null)
            {
                var ev = new EventSoucastUpdated()
                {
                    EventId    = Guid.NewGuid(),
                    Zkratka    = cmd.Zkratka,
                    Nazev      = cmd.Nazev,
                    ParentId   = cmd.ParentId,
                    ImportedId = cmd.ImportedId,
                    SoucastId  = cmd.SoucastId
                };
                ev.Generation = item.Generation + 1;
                item          = Modify(ev, item);
                await _handler.PublishEvent(ev, MessageType.SoucastUpdated, ev.EventId, item.EventGuid, ev.Generation, cmd.SoucastId);

                db.Soucasti.Update(item);
                await db.SaveChangesAsync();
            }
        }
コード例 #4
0
 public async Task Update(CommandSoucastUpdate cmd)
 {
     await _repository.Update(cmd);
 }