Example #1
0
        public UpdateContainer(Containner containner)

        {
            InitializeComponent();
            var viewModel = new UpdateContainerViewModel();

            viewModel.Container = containner;
            BindingContext      = viewModel;
        }
Example #2
0
 public void Remove()
 {
     if (Containner != null)
     {
         Containner.Remove(this);
         this.Containner = null;
     }
     else
     {
         throw new InvalidOperationException("Cannot remove ini element without containner!");
     }
 }
Example #3
0
        public async void EditContainer()
        {
            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(Container.description) || string.IsNullOrEmpty(Container.value.ToString()))
            {
                Value = true;
                return;
            }
            var _cost = new Cost
            {
                id       = Container.seaFreight.id,
                currency = Container.seaFreight.currency,
                value    = Container.seaFreight.value
            };
            var container = new Containner
            {
                id          = Container.id,
                description = Container.description,
                value       = Container.value,
                seaFreight  = _cost
            };
            var response = await apiService.Put <Containner>(
                "https://app.smart-path.it",
                "/md-core",
                "/medial/container",
                container);

            if (!response.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert("Error", response.Message, "ok");

                return;
            }
            Value = false;
            ContainerViewModel.GetInstance().Update(container);

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