public dynamic SaveCustomerOrder([FromBody] Newtonsoft.Json.Linq.JObject param)
        {
            dynamic obj             = param;
            dynamic objresponse     = null;
            int     LoginID         = Int32.Parse(_tokenData.UserID);
            string  CustomerOrderID = obj.CustomerOrderID != null ? obj.CustomerOrderID : "0";
            string  CompanyID       = _tokenData.CompanyID;

            try
            {
                var sobj = _repositoryWrapper.CustomerOrder.FindByString(CustomerOrderID);
                if (sobj != null)
                {
                    sobj.ordermonth   = obj.OrderMonth;
                    sobj.customerID   = obj.customerID;
                    sobj.status       = obj.status;
                    sobj.createuser   = LoginID;
                    sobj.userType     = false;
                    sobj.modifieddate = System.DateTime.Now;
                    sobj.inactive     = true;
                    _repositoryWrapper.CustomerOrder.Update(sobj);
                    _repositoryWrapper.EventLog.Update(sobj);

                    for (int i = 0; i < obj.data.Count; i++)
                    {
                        string CustomerOrderDetailID = obj.data[i].ID;
                        var    dobj = _repositoryWrapper.CustomerOrderDetail.FindByString(CustomerOrderDetailID);
                        dobj.customerorderDetailID = CustomerOrderDetailID;
                        dobj.customerOrderID       = CustomerOrderID;
                        dobj.productID             = obj.data[i].ProductID;
                        dobj.week1_liter           = obj.data[i].Week1;
                        dobj.week2_liter           = obj.data[i].Week2;
                        dobj.week3_liter           = obj.data[i].Week3;
                        dobj.week4_liter           = obj.data[i].Week4;
                        dobj.total        = obj.data[i].Total;
                        dobj.remark       = obj.data[i].Remark;
                        dobj.modifieddate = System.DateTime.Now;
                        dobj.inactive     = true;
                        _repositoryWrapper.CustomerOrderDetail.Update(dobj);
                        _repositoryWrapper.EventLog.Update(dobj);
                    }
                }
                else
                {
                    CustomerOrderID = _repositoryWrapper.CustomerOrder.GetCustomerOrderNo();
                    var newobj = new CustomerOrder();
                    newobj.customerOrderID = CustomerOrderID;
                    newobj.customerID      = obj.customerID;
                    newobj.ordermonth      = obj.OrderMonth;
                    newobj.status          = 1;
                    newobj.createuser      = LoginID;
                    newobj.userType        = false;
                    newobj.modifieddate    = System.DateTime.Now;
                    newobj.inactive        = true;
                    _repositoryWrapper.CustomerOrder.Create(newobj);
                    _repositoryWrapper.EventLog.Insert(newobj);

                    for (int i = 0; i < obj.data.Count; i++)
                    {
                        string CustomerOrderDetailID = _repositoryWrapper.CustomerOrderDetail.GetCustomerOrderDetailNo();
                        var    dobj = new CustomerOrderDetail();
                        dobj.customerorderDetailID = CustomerOrderDetailID;
                        dobj.customerOrderID       = CustomerOrderID;
                        dobj.productID             = obj.data[i].ProductID;
                        dobj.week1_liter           = obj.data[i].Week1;
                        dobj.week2_liter           = obj.data[i].Week2;
                        dobj.week3_liter           = obj.data[i].Week3;
                        dobj.week4_liter           = obj.data[i].Week4;
                        dobj.total        = obj.data[i].Total;
                        dobj.remark       = obj.data[i].Remark;
                        dobj.modifieddate = System.DateTime.Now;
                        dobj.inactive     = true;
                        _repositoryWrapper.CustomerOrderDetail.Create(dobj);
                        _repositoryWrapper.EventLog.Insert(dobj);
                    }
                }
                objresponse = new { data = CustomerOrderID };
            }
            catch (ValidationException vex)
            {
                _repositoryWrapper.EventLog.Error("CustomerOrder Controller/ Save CustomerOrder", vex.Message);
                objresponse = new { data = 0, error = vex.ValidationResult.ErrorMessage };
                Console.WriteLine(vex.Message);
            }

            return(objresponse);
        }
        public dynamic SaveMobileCustomerOrder([FromBody] Newtonsoft.Json.Linq.JObject param)
        {
            dynamic  objParamInfo    = param;
            dynamic  objresponse     = null;
            string   CustomerOrderID = objParamInfo.CustomerOrderID != null ? objParamInfo.CustomerOrderID : "0";
            string   CustomerID      = objParamInfo.CustomerID;
            string   OrderMonth      = objParamInfo.OrderMonth;
            string   remark          = objParamInfo.Remark;
            DateTime Date            = DateTime.Now;

            try
            {
                string customerId = _session.GetString("LoginUserID");
                if (CustomerID == customerId)
                {
                    var sobj = _repositoryWrapper.CustomerOrder.FindByString(CustomerOrderID);
                    if (sobj != null)
                    {
                        sobj.ordermonth      = objParamInfo.OrderMonth;
                        sobj.customerOrderID = objParamInfo.customerOrderID;
                        sobj.customerID      = objParamInfo.CustomerID;
                        sobj.remark          = objParamInfo.Remark;
                        sobj.createuser      = Convert.ToInt32(CustomerID);
                        sobj.userType        = true;
                        sobj.status          = objParamInfo.status;
                        sobj.modifieddate    = System.DateTime.Now;
                        sobj.inactive        = true;
                        _repositoryWrapper.CustomerOrder.Update(sobj);
                        for (int i = 0; i < objParamInfo.data.Count; i++)
                        {
                            string CustomerOrderDetailID = objParamInfo.data[i].ID;
                            var    dobj = _repositoryWrapper.CustomerOrderDetail.FindByString(CustomerOrderDetailID);
                            dobj.customerorderDetailID = CustomerOrderDetailID;
                            dobj.customerOrderID       = CustomerOrderID;
                            dobj.productID             = objParamInfo.data[i].ProductID;
                            dobj.week1_liter           = objParamInfo.data[i].Week1;
                            dobj.week2_liter           = objParamInfo.data[i].Week2;
                            dobj.week3_liter           = objParamInfo.data[i].Week3;
                            dobj.week4_liter           = objParamInfo.data[i].Week4;
                            dobj.total        = objParamInfo.data[i].Total;
                            dobj.remark       = objParamInfo.data[i].Remark;
                            dobj.modifieddate = System.DateTime.Now;
                            dobj.inactive     = true;
                            _repositoryWrapper.CustomerOrderDetail.Update(dobj);
                        }
                    }
                    else
                    {
                        CustomerOrderID = _repositoryWrapper.CustomerOrder.GetCustomerOrderNo();
                        var newobj = new CustomerOrder();
                        newobj.customerOrderID = CustomerOrderID;
                        newobj.customerID      = Convert.ToInt32(CustomerID);
                        newobj.ordermonth      = Convert.ToDateTime(OrderMonth);
                        newobj.status          = 2;
                        sobj.createuser        = Convert.ToInt32(CustomerID);
                        sobj.userType          = true;
                        newobj.modifieddate    = Date;
                        newobj.inactive        = true;
                        newobj.remark          = remark;
                        _repositoryWrapper.CustomerOrder.Create(newobj);

                        for (int i = 0; i < objParamInfo.data.Count; i++)
                        {
                            string CustomerOrderDetailID = _repositoryWrapper.CustomerOrderDetail.GetCustomerOrderDetailNo();
                            var    dobj = new CustomerOrderDetail();
                            dobj.customerorderDetailID = CustomerOrderDetailID;
                            dobj.customerOrderID       = CustomerOrderID;
                            dobj.productID             = objParamInfo.data[i].ProductID;
                            dobj.week1_liter           = objParamInfo.data[i].Week1;
                            dobj.week2_liter           = objParamInfo.data[i].Week2;
                            dobj.week3_liter           = objParamInfo.data[i].Week3;
                            dobj.week4_liter           = objParamInfo.data[i].Week4;
                            dobj.total        = objParamInfo.data[i].Total;
                            dobj.remark       = objParamInfo.data[i].Remark;
                            dobj.modifieddate = System.DateTime.Now;
                            dobj.inactive     = true;
                            _repositoryWrapper.CustomerOrderDetail.Create(dobj);
                        }
                    }
                    objresponse = new { status = 1, message = "Success" };
                }
                else
                {
                    String Message = "Sorry! Please Try Again ";
                    objresponse = new { status = 0, message = Message };
                }
            }
            catch (ValidationException vex)
            {
                //_repositoryWrapper.EventLog.Error("CustomerOrderMobile Controller/ Save CustomerOrderMobile", vex.Message);
                //objresponse = new { data = 0, error = vex.ValidationResult.ErrorMessage };
                objresponse = new { status = 0, message = "Sorry! Please Try Again" };
                Console.WriteLine(vex.Message);
            }

            return(objresponse);
        }