コード例 #1
0
        public async Task <bool> UpdateConfigAsync(T config, CancellationToken token)
        {
            bool toReturn = false;

            string           serialized = Newtonsoft.Json.JsonConvert.SerializeObject(config);
            string           typeName   = Util.Util.GetTypeName(typeof(T));
            PersistedMessage oldConfig  = await db.PeekNextAsync("config", token);

            PersistedMessage newConfig = new PersistedMessage(serialized)
            {
                Headers       = new Dictionary <string, string>()
                , MessageType = typeName
                , Ordinal     = 0
                , DateStamp   = DateTime.UtcNow
                , Status      = PersistedMessageStatusOptions.ReadyToProcess
                , Queue       = "config"
            };

            newConfig.Routes.Add(new Route()
            {
                EndPointName = "config",
                EndPointType = Publish.EndPointTypeOptions.Handler
                , Routed     = DateTime.UtcNow
            });

            toReturn = await db.PersistAsync(new List <PersistedMessage>() { newConfig }, token);

            //peek pulls latest anyway, so if this fails, no harm done
            if (oldConfig != null)
            {
                await db.MarkAsync(oldConfig.Id, PersistedMessageStatusOptions.Marked, token);
            }
            return(toReturn);
        }
コード例 #2
0
        public async Task <IActionResult> Create(CreateClientBonusCardView model)
        {
            if (ModelState.IsValid)
            {
                var client = _createClient.Create(model);
                var card   = _createBonusCard.Create(model.Balance);
                client.BonusCard = card;
                await _persist.PersistAsync(client);
            }

            return(RedirectToAction("Index"));
        }