示例#1
0
        public ResponseModel CreateShipmentAWB(int orderID, string itemIDs)
        {
            HSOrderCaller         hSOrderCaller         = new HSOrderCaller();
            ResponseModel         objResponseModel      = new ResponseModel();
            ReturnShipmentDetails returnShipmentDetails = new ReturnShipmentDetails();
            int    statusCode    = 0;
            string statusMessage = "";

            try
            {
                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();
                authenticate = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token));

                returnShipmentDetails = hSOrderCaller.InsertShipmentAWB(new HSOrderService(_connectionString), orderID, itemIDs, authenticate.TenantId, authenticate.UserMasterID, _ClientAPIUrl);
                statusCode            =
                    string.IsNullOrEmpty(returnShipmentDetails.ItemIDs) ?
                    (int)EnumMaster.StatusCode.RecordNotFound : (int)EnumMaster.StatusCode.Success;

                statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode);

                objResponseModel.Status       = true;
                objResponseModel.StatusCode   = statusCode;
                objResponseModel.Message      = statusMessage;
                objResponseModel.ResponseData = returnShipmentDetails;
            }
            catch (Exception)
            {
                throw;
            }
            return(objResponseModel);
        }
示例#2
0
        /// <summary>
        /// Get Store PinCode By UserID
        /// </summary>
        ///  <param name="tenantID"></param>
        ///  <param name="userID"></param>
        /// <returns></returns>
        public ReturnShipmentDetails CreateShipment(int orderID, string itemIDs, int tenantID, int userID, ResponseCouriersPartnerAndAWBCode responseCouriersPartnerAndAWBCode)
        {
            ReturnShipmentDetails returnShipmentDetails = null;
            DataSet ds = new DataSet();

            try
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand("SP_PHYCreateShipmentAWB", conn)
                {
                    Connection  = conn,
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.AddWithValue("@order_ID", orderID);
                cmd.Parameters.AddWithValue("@item_IDs", string.IsNullOrEmpty(itemIDs) ? "" : itemIDs.TrimEnd(','));
                cmd.Parameters.AddWithValue("@_Awb_code", string.IsNullOrEmpty(responseCouriersPartnerAndAWBCode.data.awb_code) ? "" : responseCouriersPartnerAndAWBCode.data.awb_code);
                cmd.Parameters.AddWithValue("@_CourierPartner", string.IsNullOrEmpty(responseCouriersPartnerAndAWBCode.data.courier_name) ? "" : responseCouriersPartnerAndAWBCode.data.courier_name);
                cmd.Parameters.AddWithValue("@_CourierPartnerID", string.IsNullOrEmpty(responseCouriersPartnerAndAWBCode.data.courier_company_id) ? "" : responseCouriersPartnerAndAWBCode.data.courier_company_id);
                cmd.Parameters.AddWithValue("@_CourierPartnerOrderID", string.IsNullOrEmpty(responseCouriersPartnerAndAWBCode.data.order_id) ? "" : responseCouriersPartnerAndAWBCode.data.order_id);
                cmd.Parameters.AddWithValue("@_CourierPartnerShipmentID", string.IsNullOrEmpty(responseCouriersPartnerAndAWBCode.data.shipment_id) ? "" : responseCouriersPartnerAndAWBCode.data.shipment_id);
                cmd.Parameters.AddWithValue("@tenant_ID", tenantID);
                cmd.Parameters.AddWithValue("@user_ID", userID);

                MySqlDataAdapter da = new MySqlDataAdapter
                {
                    SelectCommand = cmd
                };
                da.Fill(ds);

                if (ds != null && ds.Tables[0] != null)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        returnShipmentDetails = new ReturnShipmentDetails
                        {
                            InvoiceNo = ds.Tables[0].Rows[i]["InvoiceNo"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["InvoiceNo"]),
                            AWBNumber = ds.Tables[0].Rows[i]["AWBNo"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["AWBNo"]),
                            ItemIDs   = ds.Tables[0].Rows[i]["ItemID"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["ItemID"]),
                        };
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
            return(returnShipmentDetails);
        }
示例#3
0
        /// <summary>
        /// GetAWBInvoicenoDetails
        /// </summary>
        /// <param name="orderID"></param>
        ///  <param name="tenantID"></param>
        ///  <param name="userID"></param>
        /// <returns></returns>
        public List <ReturnShipmentDetails> GetAWBInvoicenoDetails(int orderID, int tenantID, int userID)
        {
            DataSet      ds  = new DataSet();
            MySqlCommand cmd = new MySqlCommand();
            List <ReturnShipmentDetails> lstReturnShipmentDetails = new List <ReturnShipmentDetails>();

            try
            {
                conn.Open();
                cmd.Connection = conn;
                MySqlCommand sqlcmd = new MySqlCommand("SP_PHYGetAWBInvoiceDetails", conn);
                sqlcmd.CommandType = CommandType.StoredProcedure;

                sqlcmd.Parameters.AddWithValue("order_ID", orderID);
                sqlcmd.Parameters.AddWithValue("tenant_ID", tenantID);
                sqlcmd.Parameters.AddWithValue("user_ID", userID);

                MySqlDataAdapter da = new MySqlDataAdapter();
                da.SelectCommand = sqlcmd;
                da.Fill(ds);

                if (ds != null && ds.Tables[0] != null)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        ReturnShipmentDetails returnShipmentDetails = new ReturnShipmentDetails
                        {
                            InvoiceNo = ds.Tables[0].Rows[i]["InvoiceNo"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["InvoiceNo"]),
                            ItemIDs   = ds.Tables[0].Rows[i]["ItemID"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["ItemID"]),
                            AWBNumber = ds.Tables[0].Rows[i]["AWBNo"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[0].Rows[i]["AWBNo"]),
                        };

                        lstReturnShipmentDetails.Add(returnShipmentDetails);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
            return(lstReturnShipmentDetails);
        }
示例#4
0
        /// <summary>
        /// CreateShipmentAWB
        /// </summary>
        /// <param name="orderID"></param>
        ///  <param name="itemIDs"></param>
        ///  <param name="tenantID"></param>
        ///  <param name="userID"></param>
        /// <returns></returns>
        public ReturnShipmentDetails CreateShipmentAWB(int orderID, string itemIDs, int tenantID, int userID, string clientAPIURL)
        {
            bool    isAWBGenerated  = false;
            bool    iSStoreDelivery = false;
            DataSet ds = new DataSet();
            RequestCouriersPartnerAndAWBCode  requestCouriersPartnerAndAWBCode  = null;
            ResponseCouriersPartnerAndAWBCode responseCouriersPartnerAndAWBCode = new ResponseCouriersPartnerAndAWBCode();
            ResponseGeneratePickup            responseGeneratePickup            = new ResponseGeneratePickup();
            ResponseGenerateManifest          responseGenerateManifest          = new ResponseGenerateManifest();
            ReturnShipmentDetails             obj = null;

            try
            {
                // Code for gatting data from table for request AWB client API
                if (conn != null && conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                MySqlCommand cmd = new MySqlCommand("SP_PHYGetOrderAWBDetails", conn)
                {
                    Connection  = conn,
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.AddWithValue("@_TenantID", tenantID);
                cmd.Parameters.AddWithValue("@_UserID", userID);
                cmd.Parameters.AddWithValue("@_OrderID", orderID);

                MySqlDataAdapter da = new MySqlDataAdapter
                {
                    SelectCommand = cmd
                };
                da.Fill(ds);

                if (ds != null && ds.Tables[0] != null)
                {
                    isAWBGenerated = ds.Tables[0].Rows[0]["IsAwbNoGenerated"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[0].Rows[0]["IsAwbNoGenerated"]);
                }
                if (ds != null && ds.Tables[1] != null)
                {
                    requestCouriersPartnerAndAWBCode = new RequestCouriersPartnerAndAWBCode
                    {
                        pickup_postcode   = ds.Tables[1].Rows[0]["pickup_postcode"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[1].Rows[0]["pickup_postcode"]),
                        delivery_postcode = ds.Tables[1].Rows[0]["delivery_postcode"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[1].Rows[0]["delivery_postcode"]),
                        weight            = ds.Tables[1].Rows[0]["weight"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[1].Rows[0]["weight"])
                    };
                }

                if (ds != null && ds.Tables[2] != null)
                {
                    requestCouriersPartnerAndAWBCode.orderDetails = new OrderDetails
                    {
                        order_id                = ds.Tables[2].Rows[0]["InvoiceNo"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["InvoiceNo"]),
                        order_date              = ds.Tables[2].Rows[0]["Date"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["Date"]),
                        pickup_location         = ds.Tables[2].Rows[0]["pickup_location"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["pickup_location"]),
                        channel_id              = ds.Tables[2].Rows[0]["channel_id"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["channel_id"]),
                        billing_customer_name   = ds.Tables[2].Rows[0]["CustomerName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["CustomerName"]),
                        billing_last_name       = ds.Tables[2].Rows[0]["billing_last_name"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["billing_last_name"]),
                        billing_address         = ds.Tables[2].Rows[0]["ShippingAddress"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["ShippingAddress"]),
                        billing_address_2       = ds.Tables[2].Rows[0]["billing_address_2"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["billing_address_2"]),
                        billing_city            = ds.Tables[2].Rows[0]["City"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["City"]),
                        billing_pincode         = ds.Tables[2].Rows[0]["delivery_postcode"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["delivery_postcode"]),
                        billing_state           = ds.Tables[2].Rows[0]["State"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["State"]),
                        billing_country         = ds.Tables[2].Rows[0]["Country"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["Country"]),
                        billing_email           = ds.Tables[2].Rows[0]["EmailID"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["EmailID"]),
                        billing_phone           = ds.Tables[2].Rows[0]["MobileNumber"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["MobileNumber"]),
                        billing_alternate_phone = ds.Tables[2].Rows[0]["billing_alternate_phone"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["billing_alternate_phone"]),
                        shipping_is_billing     = ds.Tables[2].Rows[0]["shipping_is_billing"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[2].Rows[0]["shipping_is_billing"]),
                        shipping_customer_name  = ds.Tables[2].Rows[0]["CustomerName"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["CustomerName"]),
                        shipping_last_name      = ds.Tables[2].Rows[0]["billing_last_name"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["billing_last_name"]),
                        shipping_address        = ds.Tables[2].Rows[0]["ShippingAddress"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["ShippingAddress"]),
                        shipping_address_2      = ds.Tables[2].Rows[0]["billing_address_2"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["billing_address_2"]),
                        shipping_city           = ds.Tables[2].Rows[0]["City"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["City"]),
                        shipping_pincode        = ds.Tables[2].Rows[0]["delivery_postcode"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["delivery_postcode"]),
                        shipping_country        = ds.Tables[2].Rows[0]["Country"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["Country"]),
                        shipping_state          = ds.Tables[2].Rows[0]["State"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["State"]),
                        shipping_email          = ds.Tables[2].Rows[0]["EmailID"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["EmailID"]),
                        shipping_phone          = ds.Tables[2].Rows[0]["MobileNumber"] == DBNull.Value ? string.Empty : Convert.ToString(ds.Tables[2].Rows[0]["MobileNumber"]),
                        payment_method          = "Prepaid",
                        shipping_charges        = 0,
                        giftwrap_charges        = 0,
                        transaction_charges     = 0,
                        total_discount          = 0,
                        sub_total               = ds.Tables[2].Rows[0]["Amount"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[2].Rows[0]["Amount"]),
                        length  = 10,
                        breadth = 10,
                        height  = 2,
                        weight  = 1.4,
                        //orderitems = new List<Orderitems>(),
                    };
                }

                if (ds != null && ds.Tables[3] != null)
                {
                    requestCouriersPartnerAndAWBCode.orderDetails.order_items = ds.Tables[3].AsEnumerable().Select(x => new Orderitems()
                    {
                        name          = x.Field <object>("name") == System.DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("name")),
                        sku           = x.Field <object>("sku") == System.DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("sku")),
                        units         = x.Field <object>("units") == System.DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("units")),
                        selling_price = x.Field <object>("selling_price") == System.DBNull.Value ? string.Empty : Convert.ToString(x.Field <object>("selling_price")),
                        discount      = x.Field <object>("discount") == System.DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("discount")),
                        tax           = x.Field <object>("tax") == System.DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("tax")),
                        hsn           = x.Field <object>("hsn") == System.DBNull.Value ? 0 : Convert.ToInt32(x.Field <object>("hsn")),
                    }).ToList();
                }
                if (ds != null && ds.Tables[4] != null)
                {
                    iSStoreDelivery = ds.Tables[4].Rows[0]["StoreDelivery"] == DBNull.Value ? false : Convert.ToBoolean(ds.Tables[4].Rows[0]["StoreDelivery"]);
                }

                if (isAWBGenerated == false)
                {
                    string apiReq = JsonConvert.SerializeObject(requestCouriersPartnerAndAWBCode);
                    apiResponse = CommonService.SendApiRequest(clientAPIURL + "api/ShoppingBag/GetCouriersPartnerAndAWBCode", apiReq);
                    responseCouriersPartnerAndAWBCode = JsonConvert.DeserializeObject <ResponseCouriersPartnerAndAWBCode>(apiResponse);
                    if (responseCouriersPartnerAndAWBCode.data.awb_code == "" && responseCouriersPartnerAndAWBCode.data.courier_name == "")
                    {
                        if (iSStoreDelivery == true)
                        {
                            //CouriersPartner =Store
                            responseCouriersPartnerAndAWBCode.data.courier_name = "Store";
                            obj = CreateShipment(orderID, itemIDs, tenantID, userID, responseCouriersPartnerAndAWBCode);
                        }
                        else
                        {
                            // insert in PHYOrderReturn table (return tab)
                            int result = SetOrderHasBeenReturn(tenantID, userID, orderID);
                        }
                    }
                    if (responseCouriersPartnerAndAWBCode.data.awb_code != "" || responseCouriersPartnerAndAWBCode.data.courier_name != "")
                    {
                        //Code for GeneratePickup
                        // { "statusCode":"200","data":{ "awb_code":"141123201505566","order_id":"41363502","shipment_id":"41079500","courier_company_id":"51","courier_name":"Xpressbees Surface","rate":100,"is_custom_rate":"0","cod_multiplier":"0","cod_charges":"0","freight_charge":"100","rto_charges":"92","min_weight":"0.5","etd_hours":"112","etd":"Jun 19, 2020","estimated_delivery_days":"5"} }
                        RequestGeneratePickup requestGeneratePickup = new RequestGeneratePickup();
                        requestGeneratePickup.shipmentId = new List <int>();
                        requestGeneratePickup.shipmentId.Add(Convert.ToInt32(responseCouriersPartnerAndAWBCode.data.shipment_id));
                        string apiReq1 = JsonConvert.SerializeObject(requestGeneratePickup);
                        apiResponse            = CommonService.SendApiRequest(clientAPIURL + "/api/ShoppingBag/GeneratePickup", apiReq1);
                        responseGeneratePickup = JsonConvert.DeserializeObject <ResponseGeneratePickup>(apiResponse);

                        // need to write Code for update Status shipment pickup

                        //end //Code for GeneratePickup need to move code

                        //Code for GenerateManifest need to move the code
                        string apiReq2 = JsonConvert.SerializeObject(requestGeneratePickup);
                        apiResponse = CommonService.SendApiRequest(clientAPIURL + "/api/ShoppingBag/GenerateManifest", apiReq2);
                        responseGenerateManifest = JsonConvert.DeserializeObject <ResponseGenerateManifest>(apiResponse);

                        // need to write Code for update Status smanifest created
                        //end Code for GenerateManifest need to move the code
                        //}
                        obj = CreateShipment(orderID, itemIDs, tenantID, userID, responseCouriersPartnerAndAWBCode);
                    }
                }

                else
                {
                    // need to write code if isAWBGenerated flag is true

                    //  code for return awb ,InvoiceNo.itemIDs need to write code (need to ask)

                    //if (responseCouriersPartnerAndAWBCode.data.awb_code != null)
                    //{
                    //    if (iSStoreDelivery == false)
                    //    {
                    //        // call rabit MQ  and update the AWB in table
                    //    }
                    //}
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }

            return(obj);
        }