コード例 #1
0
        public bool CreateOrderRecord(OrderTrackingData order, out string recordID, bool updateIfPresent = false)
        {
            //AirtableRecord record = new AirtableRecord();
            Fields fields = new Fields();

            fields.FieldsCollection = order.ToDictionary();
            var existingRecord = GetRecordByOrderID(order.OrderID.ToString(), out recordID);

            //order is present
            if (existingRecord != null)
            {
                //do not replace if present
                if (!updateIfPresent)
                {
                    return(false);
                }
                else
                {
                    var task     = _invAirtableBase.UpdateRecord(TableName, fields, recordID);
                    var response = task.Result;
                    return(task.Result.Success);
                }
            }
            else
            {
                var task     = _invAirtableBase.CreateRecord(TableName, fields);
                var response = task.Result;
                if (!task.Result.Success)
                {
                    throw new Exception(task.Result.AirtableApiError.ErrorMessage);
                }
                recordID = response.Record.Id;
                return(task.Result.Success);
            }
        }
コード例 #2
0
        public bool DeleteOrderRecord(OrderTrackingData order)
        {
            var existingRecord = GetRecordByOrderID(order.OrderID.ToString(), out string recordID);
            var task           = _invAirtableBase.DeleteRecord(TableName, recordID);
            var response       = task.Result;

            return(task.Result.Success);
        }
コード例 #3
0
        public OrderTrackingData NewOrderTrackingData(string orderID)
        {
            OrderTrackingData a = new OrderTrackingData(orderID, _namesTable.GetNamesLookup());

            if (a is null)
            {
                throw new ArgumentNullException();
            }
            return(a);
        }
コード例 #4
0
        public bool UpdateOrderRecord(OrderTrackingData order)
        {
            Fields fields = new Fields();

            fields.FieldsCollection = order.ToDictionary();
            var existingRecord = GetRecordByOrderID(order.OrderID.ToString(), out string recordID);
            var task           = _invAirtableBase.UpdateRecord(TableName, fields, recordID);
            var response       = task.Result;

            return(task.Result.Success);
        }
コード例 #5
0
        public OrderTrackingData OrderDataToOrderTrackingData(OrderData orderData)
        {
            OrderTrackingData orderTrackingData = new OrderTrackingData(orderData.OrderID, _namesTable.GetNamesLookup());

            orderTrackingData.Description   = orderData.Description;
            orderTrackingData.Notes         = orderData.Notes;
            orderTrackingData.PrintOperator = orderData.PrintOperator;
            orderTrackingData.DueDate       = orderData.DueDate;
            orderTrackingData.Shipper       = orderData.Shipper;
            orderTrackingData.ShipDate      = orderData.ShipDate;
            orderTrackingData.Priority      = orderData.Rush;
            orderTrackingData.OrderURL      = orderData.OrderURL;
            orderTrackingData.OrderValue    = orderData.TotalPrice - orderData.ShippingCharge - orderData.MaterialCost - orderData.SalesTax;
            orderTrackingData.Channel       = orderData.Channel;

            if (orderTrackingData is null)
            {
                throw new ArgumentNullException();
            }
            return(orderTrackingData);
        }