示例#1
0
        public UpdateClosureCalendarPage(ClosureCalendar closureCalendar)
        {
            InitializeComponent();
            var viewModel = new UpdateClosureCalendarViewModel();

            viewModel.ClosureCalendar = closureCalendar;
            BindingContext            = viewModel;
        }
 private async void Update_Closure_Calendar(object sender, EventArgs e)
 {
     // var mi = ((MenuItem)sender);
     //var closureCalendar = mi.CommandParameter as ClosureCalendar;
     TappedEventArgs tappedEventArgs = (TappedEventArgs)e;
     ClosureCalendar closureCalendar = ((ClosureCalendarViewModel)BindingContext).ClosureCalendar.Where(ser => ser.id == (int)tappedEventArgs.Parameter).FirstOrDefault();
     await PopupNavigation.Instance.PushAsync(new UpdateClosureCalendarPage(closureCalendar));
 }
示例#3
0
        public async void EditClosureCalendar()
        {
            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(ClosureCalendar.code) || string.IsNullOrEmpty(ClosureCalendar.period))
            {
                Value = true;
                return;
            }
            var closureCalendar = new ClosureCalendar
            {
                id        = ClosureCalendar.id,
                code      = ClosureCalendar.code,
                period    = ClosureCalendar.period,
                startDate = ClosureCalendar.startDate,
                endDate   = ClosureCalendar.endDate
            };
            var cookie = Settings.Cookie;  //.Split(11, 33)
            var res    = cookie.Substring(11, 32);

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

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

                return;
            }
            Value = false;
            ClosureCalendarViewModel.GetInstance().Update(closureCalendar);

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