示例#1
0
        public IViewComponentResult Invoke(string title)
        {
            ViewBag.Title = title;
            var s = new SOC();
            s.Init();
            ViewBag.newSoc = s;

            return View(_query.GetList());
        }
示例#2
0
        public IActionResult AddSoc(SOC newSoc)
        {
            _data.AddOrUpdateSoc(newSoc,(newId)=>
            {
                //Update base query store
                var d = _data.GetSoc(newId);
                var state = new SOCState() { AggregateId=d.AggregateId,Title=d.Titel,LastUpdated=d.UpDateTime };
                _queryStore.Upsert(state);
                var statistics=_data.GetList(newSoc.AggregateId).Count();

                //update statistics store
                var stat = new SOCStatistics() { AggregateId = newSoc.AggregateId, Title = newSoc.Titel, LastUpdated = newSoc.UpDateTime, NoOfUpdates = statistics };
                _statistics.Upsert(stat);
            });
            return RedirectToAction("Index");
        }
示例#3
0
        public void AddOrUpdateSoc(SOC soc, Action<Guid> processor)
        {
            Guid theId;
            if (soc.AggregateId==Guid.Empty)
            {
                soc.Init();
                soc.AggregateId = Guid.NewGuid();
                var stream = new List<SOC>();
                stream.Add(soc);
                aggregates.Add(soc.AggregateId, stream);
                theId = soc.Id;
            }
            else
            {
                List<SOC> stream=new List<SOC>();
                if (aggregates.TryGetValue(soc.AggregateId, out stream))
                {
                    SOC newSoc = new SOC()
                    {
                        AggregateId = soc.AggregateId,
                        CreateTime = soc.CreateTime,
                        Description = soc.Description,
                        Id = Guid.NewGuid(),
                        Observation = soc.Observation,
                        Titel = soc.Titel,
                        UpDateTime = DateTime.Now,
                        Version = ++soc.Version
                    };

                    stream.Add(newSoc);
                    theId = newSoc.Id;
                }
                else
                {
                    throw new Exception("Unknown SOC");
                }
            }
            processor.Invoke(theId);
        }