Exemple #1
0
        async void Upload()
        {
            var answer = await dialogService.ShowConfirm(
                "Confirmación",
                "¿Está seguro de iniciar una nueva carga de datos?");

            if (!answer)
            {
                return;
            }

            var connection = await netService.CheckConnectivity();

            if (!connection.IsSuccess)
            {
                await dialogService.ShowMessage("Error", connection.Message);

                return;
            }


            //var mainViewModel = MainViewModel.GetInstance();
            //DataService dataService = new DataService();
            //var Shiptolist = dataService.Get<ShipTo>(false)
            //.Where(s => s.CreateinPhone == true).ToList();
            //var url = Application.Current.Resources["URLAPI"].ToString();

            //foreach (var item in Shiptolist)
            //{
            //    var shiptorequest = new SyncShiptoRequest
            //    {
            //        ShipToId = item.ShipToId,
            //        CustomerId = item.CustomerId,
            //        ShipToNum = item.ShipToNum,
            //        CustNum = item.CustNum,
            //        Company = item.Company,
            //        ShipToName = item.ShipToName,
            //        TerritoryEpicorId = item.TerritoryEpicorId,
            //        Country = item.Country,
            //        State = item.State,
            //        City = item.City,
            //        Address = item.Address,
            //        PhoneNum = item.PhoneNum,
            //        Email = item.Email,
            //        VendorId = mainViewModel.User.VendorId,
            //        SincronizadoEpicor = false,
            //    };
            //    var answerresult = await apiService.PostMaster(url, "/ShipToes", shiptorequest);
        }
Exemple #2
0
        async void Download()
        {
            var answer = await dialogService.ShowConfirm(
                "Confirmación",
                "¿Está seguro de iniciar una nueva descarga?");

            if (!answer)
            {
                return;
            }

            var connection = await netService.CheckConnectivity();

            if (!connection.IsSuccess)
            {
                await dialogService.ShowMessage("Error", connection.Message);

                return;
            }

            await BeginDownload();
        }
        async void Login()
        {
            if (string.IsNullOrEmpty(Email))
            {
                await dialogService.ShowMessage("Error", "Debes ingresar un email.");

                Password = null;
                return;
            }

            if (string.IsNullOrEmpty(Password))
            {
                await dialogService.ShowMessage("Error", "Debes ingresar una contraseña.");

                Password = null;
                return;
            }

            var connection = await netService.CheckConnectivity();

            if (!connection.IsSuccess)
            {
                await dialogService.ShowMessage("Error", connection.Message);

                return;
            }

            IsRunning = true;
            IsEnabled = false;
            var url      = Application.Current.Resources["URLAPI"].ToString();
            var response = await apiService.Login(url, "/api/users/login",
                                                  Email, Password);

            IsRunning = false;
            IsEnabled = true;

            if (!response.IsSuccess)
            {
                await dialogService.ShowMessage("Error", response.Message);

                Password = null;
                return;
            }

            Email    = null;
            Password = null;

            var user = (User)response.Result;

            var deviceId = CrossDevice.Hardware.DeviceId;

            if (user.IMEI != deviceId)
            {
                await dialogService.ShowMessage("Error", "Se esta intentando loguear desde un equipo no autorizado");

                return;
            }

            user.IsRemembered = IsRemembered;
            user.Password     = Password;
            dataService.DeleteAllAndInsert(user);
            var mainViewModel = MainViewModel.GetInstance();

            mainViewModel.User   = user;
            mainViewModel.Orders = new OrdersViewModel();
            navigationService.SetMainPage("MasterPage");
        }
Exemple #4
0
        async void SaveShipTo()
        {
            try
            {
                var answer = await dialogService.ShowConfirm(
                    "Confirmación",
                    "¿Guardar sucursal?");

                var connection = await netService.CheckConnectivity();

                if (!connection.IsSuccess)
                {
                    await dialogService.ShowMessage("Error", connection.Message);

                    return;
                }

                if (string.IsNullOrEmpty(NewShipTo.ShipToNum))
                {
                    await dialogService.ShowMessage(
                        "Error",
                        "Debes ingresar un ShipToNum.");

                    return;
                }

                if (string.IsNullOrEmpty(NewShipTo.ShipToName))
                {
                    await dialogService.ShowMessage(
                        "Error",
                        "Debes ingresar nombre de sucursal.");

                    return;
                }

                if (string.IsNullOrEmpty(NewShipTo.Description))
                {
                    await dialogService.ShowMessage(
                        "Error",
                        "Debes seleccionar un pais.");

                    return;
                }

                NewShipTo.IsRunning = true;

                //var UltimoRegistro = dataService
                //.Get<ShipTo>(false)
                //.OrderByDescending(t => t.ShipToId)
                //.FirstOrDefault();

                //if (UltimoRegistro.ShipToId == 0)
                //{
                //    UltimoRegistro.ShipToId = 1;

                //}else{

                //    UltimoRegistro.ShipToId = UltimoRegistro.ShipToId + 1;
                //}

                var shipto = new ShipTo
                {
                    ShipToId          = 0,
                    CustomerId        = NewShipTo.CustomerId,
                    CustNum           = EditCustomer.Customer.CustNum,
                    ShipToNum         = NewShipTo.ShipToNum,
                    Company           = User.Company,
                    ShipToName        = NewShipTo.ShipToName,
                    TerritoryEpicorID = NewShipTo.TerritoryEpicorID,
                    Country           = NewShipTo.Description,
                    State             = NewShipTo.State,
                    City               = NewShipTo.City,
                    Address            = NewShipTo.Address,
                    PhoneNum           = NewShipTo.PhoneNum,
                    Email              = NewShipTo.Email,
                    SincronizadoEpicor = false,
                };



                #region Sincronizo Shipto
                var url = Application.Current.Resources["URLAPI"].ToString();

                var shiptorequest = new SyncShiptoRequest
                {
                    ShipToId          = shipto.ShipToId,
                    CustomerId        = shipto.CustomerId,
                    ShipToNum         = shipto.ShipToNum,
                    CustNum           = shipto.CustNum,
                    Company           = shipto.Company,
                    ShipToName        = shipto.ShipToName,
                    TerritoryEpicorID = shipto.TerritoryEpicorID,
                    Country           = shipto.Country,
                    State             = shipto.State,
                    City               = shipto.City,
                    Address            = shipto.Address,
                    PhoneNum           = shipto.PhoneNum,
                    Email              = shipto.Email,
                    VendorId           = User.VendorId,
                    SincronizadoEpicor = false,
                };


                var response = await apiService
                               .PostMaster(url, "/api/ShipToes", shiptorequest);

                if (!response.IsSuccess)
                {
                    await dialogService.ShowMessage("Error", response.Message);

                    return;
                }

                var syncShiptoRequest = (SyncShiptoRequest)response.Result;
                var ShipToToInsert    = new ShipTo
                {
                    Address            = syncShiptoRequest.Address,
                    City               = syncShiptoRequest.City,
                    Company            = syncShiptoRequest.Company,
                    Country            = syncShiptoRequest.Country,
                    CustNum            = syncShiptoRequest.CustNum,
                    CustomerId         = syncShiptoRequest.CustomerId,
                    Email              = syncShiptoRequest.Email,
                    PhoneNum           = syncShiptoRequest.PhoneNum,
                    ShipToId           = syncShiptoRequest.ShipToId,
                    ShipToName         = syncShiptoRequest.ShipToName,
                    ShipToNum          = syncShiptoRequest.ShipToNum,
                    SincronizadoEpicor = syncShiptoRequest.SincronizadoEpicor,
                    State              = syncShiptoRequest.State,
                    TerritoryEpicorID  = syncShiptoRequest.TerritoryEpicorID,
                    VendorId           = User.VendorId,
                };

                dataService.Insert(ShipToToInsert);
                NewShipTo.IsRunning = false;
                await dialogService.ShowMessage("Exito", "Se inserto el registro con exito.");

                EditCustomer.RefreshShipTo();
                await navigationService.Back();

                #endregion
            }
            catch (Exception ex)
            {
                await dialogService.ShowMessage("Error", ex.Message);
            }
        }