Exemple #1
0
        public void InsertDutchNedInsertedOrderlinestatus()
        {
            DutchNedInsertedOrderlinestatusRepository dnRepo = new DutchNedInsertedOrderlinestatusRepository();

            var item = new DutchNedInsertedOrderlinestatus()
            {
                Status      = 201,
                Description = "Dit is een test",
                OrderLineId = 999
            };

            dnRepo.Insert(item);
        }
        protected override void ExecutePost(Request request)
        {
            try
            {
                // Get json
                var jsonString = request.Response.Detail;

                var response = JsonConvert.DeserializeObject <DNResponse>(jsonString);

                foreach (var result in response.Results)
                {
                    string description = "Unknown";
                    switch (result.StatusCode)
                    {
                    case 600:
                        description = "Imported new";
                        break;

                    case 601:
                        description = "Imported and automatically planned based on other delivery-order";
                        break;

                    case 602:
                        description = "Imported added to another delivery-order";
                        break;

                    case 603:
                        description = "Updated";
                        break;

                    case 604:
                        description = "Can’t be changed already planned";
                        break;

                    case 605:
                        description = "{ Exception: {" + JsonConvert.SerializeObject(result.Exception) + "}}";
                        break;
                    }
                    var status = new DutchNedInsertedOrderlinestatus()
                    {
                        Status      = result.StatusCode,
                        Description = description,
                        OrderLineId = Convert.ToInt32(result.OrderlineId)
                    };

                    _statusRepository.Insert(status);
                }
                try
                {
                    if (request.Response.Code == 200)
                    {
                        APITaskManagement.Logic.Api.Models.DutchNedSalesOrderDto salesOrder = JsonConvert.DeserializeObject <APITaskManagement.Logic.Api.Models.DutchNedSalesOrderDto>(request.Body);

                        foreach (var line in salesOrder.Lines)
                        {
                            var cashOnDelivery = new CashOnDeliveryOrderline()
                            {
                                OrderlineId    = Convert.ToInt32(line.Id),
                                CashOnDelivery = line.CashOnDelivery
                            };

                            _cashOnDeliveryOrderlineRepository.Insert(cashOnDelivery);
                        }
                    }
                }
                catch
                {
                }
            }
            catch
            {
            }
        }