private bool Subscribe(string message, IDictionary <string, object> header)
        {
            var response = JsonConvert.DeserializeObject <Domain.Model.Inventory>(message);

            try
            {
                if (response.IsSuccess)
                {
                    var hdl = new HandlerModel();
                    hdl.Message = "Berhasil disimpan";

                    invRepository.Update(response.ProductID, response.Stock).GetAwaiter().GetResult();
                    hdl.Result  = true;
                    hdl.OrderID = response.OrderID;
                    publisher.Publish(JsonConvert.SerializeObject(hdl), "handler.event", null);
                }
            }
            catch
            {
                var order = new Order();
                order.OrderID   = response.OrderID;
                order.IsSuccess = false;

                publisher.Publish(JsonConvert.SerializeObject(order), "order.event", null);
            }

            return(true);
        }
        private void IndexHandler(ResourceModel resource, HandlerModel handler, ResourceMetadata metadata)
        {
            var exclusions = new List <string> {
                "ToString", "GetType", "GetHashCode", "Equals"
            };

            foreach (var uri in metadata.Uris)
            {
                var candidateMethods = handler.Type.StaticType.GetMethods()
                                       .Where(x => x.IsPublic)
                                       .Where(x => !exclusions.Contains(x.Name))
                                       .Where(x => !x.IsSpecialName)
                                       .Where(x => !IsMethodObsolete(x))
                                       .ToList();

                foreach (var publicMethod in candidateMethods)
                {
                    var operation = new OperationMetadata(uri, resource.ResourceKey as IType);

                    if (DiscoveryRules.All(x => x.Discover(publicMethod, operation)))
                    {
                        metadata.Add(operation);
                        operation.Group = _grouper.Group(resource, uri, operation);
                    }
                }
            }
        }
        private bool Subscribe(string message, IDictionary <string, object> header)
        {
            var response = JsonConvert.DeserializeObject <Domain.Model.Order>(message);
            var hdl      = new HandlerModel();

            try
            {
                if (response.IsSuccess)
                {
                    var inv = new Inventory();
                    inv.ProductID = response.ProductID;
                    inv.Stock     = response.Quantity;
                    inv.OrderID   = response.OrderID;

                    this.orderRepository.Create(response).GetAwaiter().GetResult();
                    inv.IsSuccess = true;
                    publisher.Publish(JsonConvert.SerializeObject(inv), "inventory.event", null);

                    hdl.Result  = false;
                    hdl.Message = "Create udah berhasil, tinggal masuk inventory";
                    hdl.OrderID = response.OrderID;

                    publisher.Publish(JsonConvert.SerializeObject(hdl), "handler.event", null);
                }
                else
                {
                    hdl.Result  = false;
                    hdl.Message = "Inventory Gagal Euuuyyy";
                    hdl.OrderID = response.OrderID;

                    this.orderRepository.Delete(response.OrderID).GetAwaiter().GetResult();
                    publisher.Publish(JsonConvert.SerializeObject(hdl), "handler.event", null);
                }
            }
            catch (Exception ex)
            {
                hdl.Result  = false;
                hdl.Message = ex.Message;
                hdl.OrderID = response.OrderID;

                publisher.Publish(JsonConvert.SerializeObject(hdl), "handler.event", null);
            }

            return(true);
        }
Exemplo n.º 4
0
 public ActionResult Create(HandlerModel model)
 {
     try
     {
         PostalTerminalHandler handler = new PostalTerminalHandler()
         {
             PostalTerminals_Id = model.PostalTerminals_Id,
             Handlers_User_id   = model.Handlers_User_id
         };
         context.PostalTerminalHandlers.InsertOnSubmit(handler);
         context.SubmitChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(model));
     }
 }
Exemplo n.º 5
0
        public IActionResult Add(Order data)
        {
            try
            {
                var datahandler = new HandlerModel();
                datahandler.OrderID = data.OrderID;
                datahandler.Result  = false;
                datahandler.Message = "Pending";

                this.Handler.Insert(datahandler);
                data.IsSuccess = true;
                publisher.Publish(JsonConvert.SerializeObject(data), "order.event", null);

                return(Ok("Sukses"));
            }
            catch (System.Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Exemplo n.º 6
0
 public void RemoveHandler(HandlerModel handler) =>
 _handlerModels.Remove(handler);
Exemplo n.º 7
0
 public void AddHandler(HandlerModel handler) =>
 _handlerModels.Add(handler);
        public ActionResult RemoveHandler(string path)
        {
            HandlerModel handler = new HandlerModel(path);

            return(View(handler));
        }
Exemplo n.º 9
0
 public HandlerViewModel(Model model) : base(model)
 {
     Model = new HandlerModel();
     Job   = new Job();
 }
Exemplo n.º 10
0
 public HandlerViewModel(Model model)
     : base(model)
 {
     Model = new HandlerModel();
     Job = new Job();
 }
Exemplo n.º 11
0
        public ActionResult Create()
        {
            HandlerModel model = new HandlerModel();

            return(View(model));
        }