예제 #1
0
        public UpdateSIAPECPage(Siapec siapec)
        {
            InitializeComponent();
            var updateSiapecViewModel = new UpdateSIAPECViewModel();

            updateSiapecViewModel.Siapec = siapec;
            BindingContext = updateSiapecViewModel;
        }
예제 #2
0
        public async void EditSIAPEC()
        {
            Value = true;
            var connection = await apiService.CheckConnection();

            if (!connection.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Warning,
                    Languages.CheckConnection,
                    Languages.Ok);

                return;
            }
            if (string.IsNullOrEmpty(Siapec.code) || string.IsNullOrEmpty(Siapec.description) || Siapec.branch == null)
            {
                Value = true;
                return;
            }
            var siapec = new Siapec
            {
                id          = Siapec.id,
                code        = Siapec.code,
                description = Siapec.description,
                branch      = Siapec.branch,
                codRL       = Siapec.codRL,
                isExist     = Siapec.isExist
            };
            var cookie = Settings.Cookie;  //.Split(11, 33)
            var res    = cookie.Substring(11, 32);

            var response = await apiService.Put <Siapec>(
                "https://portalesp.smart-path.it",
                "/Portalesp",
                "/siapec/update",
                res,
                siapec);

            Debug.WriteLine("********responseIn ViewModel*************");
            Debug.WriteLine(response);
            if (!response.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert("Error", response.Message, "ok");

                return;
            }
            Value = false;
            SiapecViewModel.GetInstance().Update(siapec);

            DependencyService.Get <INotification>().CreateNotification("PortalSP", "SIAPEC Updated");
            await App.Current.MainPage.Navigation.PopPopupAsync(true);
        }