/// <summary>
        /// Get one row from CustomClearanceView
        /// </summary>
        /// <param name="id">Custom Clearance Id</param>
        /// <returns>CustomClearanceView object</returns>
        internal static CustomClearanceView GetOneCustClearView(int ccId)
        {
            OperationsEntities  db           = new OperationsEntities();
            CustomClearanceView custClearObj = db.CustomClearanceViews.Where(x => x.CCId == ccId).FirstOrDefault();

            return(custClearObj);
        }
        /// <summary>
        /// Get all custom clearance orders for grid
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        internal static JObject GetCCAllOrders(FormCollection form)
        {
            OperationsEntities         db            = new OperationsEntities();
            List <CustomClearanceView> operationList = new List <CustomClearanceView>();
            CustomClearanceView        oprObj        = new CustomClearanceView();

            if (form.Count > 0)
            {
                string where  = CommonHelper.AdvancedSearch <CustomClearanceView>(form, oprObj);
                operationList = db.CustomClearanceViews.Where(where.ToString()).ToList();
            }
            else
            {
                operationList = db.CustomClearanceViews
                                .Where(x => x.StatusId == 1 || x.StatusId == 2)
                                .OrderByDescending(x => x.CreateDate).ToList();
            }

            operationList = operationList.OrderByDescending(x => x.CreateDate).ToList();


            JTokenWriter pJTokenWriter = new JTokenWriter();
            JObject      ordersJson    = new JObject();

            pJTokenWriter.WriteStartObject();
            pJTokenWriter.WritePropertyName("data");
            pJTokenWriter.WriteStartArray();
            foreach (var item in operationList)
            {
                pJTokenWriter.WriteStartObject();

                pJTokenWriter.WritePropertyName("CCId");
                pJTokenWriter.WriteValue(item.CCId);

                pJTokenWriter.WritePropertyName("OperationId");
                pJTokenWriter.WriteValue(item.OperationId);

                pJTokenWriter.WritePropertyName("CarrierTypeImg");
                switch (item.CarrierType)
                {
                case 1:
                    pJTokenWriter.WriteValue("<i class='fa fa-ship'></i>");
                    break;

                case 2:
                    pJTokenWriter.WriteValue("<i class='fa fa-plane'></i>");
                    break;
                }


                switch (item.OrderFrom)
                {
                case 1:
                    pJTokenWriter.WritePropertyName("OrderFromImg");
                    pJTokenWriter.WriteValue("<i class='fa fa-level-up'></i>");

                    pJTokenWriter.WritePropertyName("Client");
                    pJTokenWriter.WriteValue(item.ShipperNameEn);

                    pJTokenWriter.WritePropertyName("Port");
                    pJTokenWriter.WriteValue(item.FromPort);

                    break;

                case 2:
                    pJTokenWriter.WritePropertyName("OrderFromImg");
                    pJTokenWriter.WriteValue("<i class='fa fa-level-down'></i>");

                    pJTokenWriter.WritePropertyName("Client");
                    pJTokenWriter.WriteValue(item.ConsigneeNameEn);

                    pJTokenWriter.WritePropertyName("Port");
                    pJTokenWriter.WriteValue(item.ToPort);
                    break;
                }

                pJTokenWriter.WritePropertyName("CarrierType");
                pJTokenWriter.WriteValue(item.CarrierType);

                pJTokenWriter.WritePropertyName("MBL");
                pJTokenWriter.WriteValue(item.MBL);

                pJTokenWriter.WritePropertyName("OperationCode");
                pJTokenWriter.WriteValue(item.OperationCode);

                pJTokenWriter.WritePropertyName("BookingNumber");
                pJTokenWriter.WriteValue(item.BookingNumber);

                pJTokenWriter.WritePropertyName("NeedArrive");
                pJTokenWriter.WriteValue(item.NeedArriveDate.ToString("dd/MM/yyyy") + " " + item.NeedArriveTime.ToString(@"h\:mm"));

                pJTokenWriter.WritePropertyName("StatusName");
                pJTokenWriter.WriteValue(item.StatusName);

                pJTokenWriter.WriteEndObject();
            }

            pJTokenWriter.WriteEndArray();
            pJTokenWriter.WriteEndObject();
            ordersJson = (JObject)pJTokenWriter.Token;
            return(ordersJson);
        }