public JsonResult SetBilling2(string value, string Billing, DateTime date)
        {
            try
            {
                FacadeLog.MobileWriteEntry("Order/SetBilling|" + Billing);
                ModelViewUserG   objCred = new JavaScriptSerializer().Deserialize <ModelViewUserG>(value);
                ModelViewBilling obj     = new JavaScriptSerializer().Deserialize <ModelViewBilling>(Billing);

                if (obj.EstimatedTipe == 2)
                {
                    var result = FacadePolicy.SetPolicyQuotation(objCred, obj);
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                if (obj.EstimatedTipe == 3)
                {
                    var result = FacadePolicy.SetRefQuotation(objCred, obj);
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    var result = FacadeOrder.SetQuotation2(objCred, obj, date);
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public JsonResult SetPayment(string data)
        {
            try
            {
                FacadeLog.MobileWriteEntry("Order/SetPayment|" + data);
                ModelViewPayment model = new JavaScriptSerializer().Deserialize <ModelViewPayment>(data);
                var result             = FacadePayment.SetPayment(model);

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public JsonResult SetOrderSecuence(string data)
        {
            try
            {
                FacadeLog.MobileWriteEntry("Order/SetOrderSecuence|" + data);

                ModelViewUserSecuence Data = new JavaScriptSerializer().Deserialize <ModelViewUserSecuence>(data);
                FacadeOrder.SetOrderSecuence(Data);

                return(Json("Sucess"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public JsonResult SetADRReserveSP(string data)
        {
            try
            {
                FacadeLog.MobileWriteEntry("Order/SetADRReserveSP|" + data);

                List <ModelViewApartadoADR> dataRef = new JavaScriptSerializer().Deserialize <List <ModelViewApartadoADR> >(data);
                ModelViewResultREST         result  = FacadeInterface.SetADRReserveSP(dataRef);

                return(Json(result));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public JsonResult GetShopPlace(string value)
        {
            try
            {
                ModelViewUserG objCred = new JavaScriptSerializer().Deserialize <ModelViewUserG>(value);

                if (!objCred.Date.HasValue)
                {
                    FacadeLog.MobileWriteEntry("Order/GetShopPlace|FirstSync|" + value);

                    var detail = new List <ModelViewDetail>();
                    detail.Add(new ModelViewDetail()
                    {
                        Battery        = "--",
                        ConnectionType = "--",
                        Date           = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        InnerException = "--",
                        Message        = "Primera sincronización",
                        Module         = "app.activities.SynchronizationActivity",
                        OrderID        = "--",
                        SignPercentage = "--",
                        SignType       = "--",
                        StackTrace     = "--",
                        TokenLog       = "",
                        Type           = "Information",
                        version        = "--"
                    });

                    ModelViewLog dataODS = new ModelViewLog()
                    {
                        TokenApp  = objCred.TokenApp,
                        TokenUser = objCred.TokenUser,
                        Detail    = detail
                    };
                    var token = FacadeLogMobile.Insert(dataODS);
                }

                var lt = FacadeShopPlace.GetListShopPlace(objCred);
                return(Json(lt, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public JsonResult SetLogMobile(string data)
        {
            try
            {
                FacadeLog.MobileWriteEntry("Order/SetLogMobile|" + data);

                ModelViewLog dataODS = new JavaScriptSerializer().Deserialize <ModelViewLog>(data);
                var          token   = FacadeLogMobile.Insert(dataODS);

                ModelViewResultREST result = new ModelViewResultREST();
                result.Result = "Success" + "|" + token;
                return(Json(result));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public JsonResult SetOrder(string data)
        {
            try
            {
                FacadeLog.MobileWriteEntry("Order/SetOrder|" + data);

                ModelViewODSMovilUploadList dataODS = new JavaScriptSerializer().Deserialize <ModelViewODSMovilUploadList>(data);
                var ordens = FacadeOrder.Complete(dataODS);

                ModelViewResultREST result = new ModelViewResultREST();
                result.Result = "Success" + "|" + ordens;
                return(Json(result));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public JsonResult SetPreOrder(string data)
        {
            try
            {
                FacadeLog.MobileWriteEntry("Order/SetPreOrder|" + data);

                ModelViewPreODS dataODS = new JavaScriptSerializer().Deserialize <ModelViewPreODS>(data);
                FacadeOrder.Complete(dataODS);

                ModelViewResultREST result = new ModelViewResultREST();
                result.Result = "Success";

                return(Json(result));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public JsonResult GetValidationODS(string data)
        {
            try
            {
                FacadeLog.MobileWriteEntry(data);

                ModelViewUserVisits objCred = new JavaScriptSerializer().Deserialize <ModelViewUserVisits>(data);

                var result = FacadeOrder.GetReprogramingODS(objCred);


                return(Json(result, JsonRequestBehavior.AllowGet));
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
        public JsonResult UpdateSparePartsODS(string data)
        {
            try
            {
                FacadeLog.MobileWriteEntry("Order/UpdateSparePartsODS|" + data);

                List <SparePart> dataSparePartsODS = new JavaScriptSerializer().Deserialize <List <SparePart> >(data);
                FacadeSparePart.UpdateSparePartsODS(dataSparePartsODS);

                ModelViewResultREST result = new ModelViewResultREST();
                result.Result = "Success";

                return(Json(result));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public JsonResult GetListVisit(string ListVisit)
        {
            ModelViewUserVisits objCred = new JavaScriptSerializer().Deserialize <ModelViewUserVisits>(ListVisit);

            try
            {
                string Usuario = FacadeUsers.GetUserByToken(objCred.TokenUser).UserName;
                FacadeLog.MobileWriteEntry(Usuario + " INICIO_DescargaODS ");
                var lt = FacadeOrder.GetListOrden(objCred);

                FacadeLog.MobileWriteEntry(Usuario + " FIN_DescargaODS ");

                return(Json(lt, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                throw new Generic_Exception(ex, Generic_Exception.ErrorCodes.ErrorGoogleMaps);
            }
        }