Esempio n. 1
0
        public virtual async Task <IActionResult> Index(ToonViewModel model)
        {
            await _context.Toons.AddAsync(new Toon { Name = model.Name, Order = model.Order });

            await _context.SaveChangesAsync();

            try
            {
                await ChildIndex(model);
            }
            catch (Exception ex)
            {
                ViewBag.Ex = ex;

                return(Index());
            }

            return(RedirectToAction("Index"));
        }
        protected override async Task ChildIndex(ToonViewModel model)
        {
            var url = string.Empty;

            switch (model.Order)
            {
            case Order.Jedi:
                url = "http://localhost:5001/api/jedis";
                break;

            case Order.Sith:
                url = "http://localhost:5002/api/siths";
                break;
            }

            var response = await _client.PostAsJsonAsync <IDictionary <string, string> >(url, new Dictionary <string, string> {
                { "name", model.Name }
            });

            if (!response.IsSuccessStatusCode)
            {
            }
        }
Esempio n. 3
0
 protected abstract Task ChildIndex(ToonViewModel model);
Esempio n. 4
0
 protected override async Task ChildIndex(ToonViewModel model)
 {
     QueueConnector.Instance.Publish(JsonConvert.SerializeObject(model));
 }