Esempio n. 1
0
        private static ObservableCollection <SelectableViewModel <DisplayMecanic> > GetMecanicsData()
        {
            var obsCollenctionTemp = new ObservableCollection <SelectableViewModel <DisplayMecanic> >();

            if (!CommonItem.DemoApp)
            {
                using (var autoApi = new AutoServiceClient())
                {
                    _clientMecanics = autoApi.GetAvailabelMecanics();

                    foreach (var mecanic in _clientMecanics)
                    {
                        obsCollenctionTemp.Add(
                            new SelectableViewModel <DisplayMecanic>
                        {
                            IsChecked = false,
                            Item      = new DisplayMecanic()
                            {
                                Id = mecanic.Id, FullName = $"{mecanic.Nume} {mecanic.Prenume}"
                            }
                        });
                    }
                }
            }
            else
            {
                obsCollenctionTemp.Add(
                    new SelectableViewModel <DisplayMecanic>
                {
                    IsChecked = false,
                    Item      = new DisplayMecanic()
                    {
                        Id       = Guid.NewGuid(),
                        FullName = "Janita Filice"
                    }
                });
                obsCollenctionTemp.Add(
                    new SelectableViewModel <DisplayMecanic>
                {
                    IsChecked = false,
                    Item      = new DisplayMecanic()
                    {
                        Id       = Guid.NewGuid(),
                        FullName = "Ronni Orman"
                    }
                });
                obsCollenctionTemp.Add(
                    new SelectableViewModel <DisplayMecanic>
                {
                    IsChecked = true,
                    Item      = new DisplayMecanic()
                    {
                        Id       = Guid.NewGuid(),
                        FullName = "Devona Millet"
                    }
                });
            }

            return(obsCollenctionTemp);
        }
Esempio n. 2
0
        private void AddCommandButtonClick(object sender, RoutedEventArgs e)
        {
            BuildComanda();

            if (!CommonItem.DemoApp)
            {
                using (var autoApi = new AutoServiceClient())
                {
                    try
                    {
                        var response = autoApi.CreateDetaliuComanda(_detaliuComanda);

                        if (!response)
                        {
                            return;
                        }
                        CommonItem.PageInstent.Clear();
                        CommonItem.GetFrame().NavigationService.Navigate(new Dashboard());
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.ToString());
                    }
                }
            }
            else
            {
                CommonItem.PageInstent.Clear();
                CommonItem.GetFrame().NavigationService.Navigate(new Dashboard());
            }
        }
Esempio n. 3
0
        private void AddComandaButtonClick(object sender, RoutedEventArgs e)
        {
            DialogResult userResponse;

            if (Operations.Count == 0)
            {
                MessageBox.Show(@"Scuze, dar ca sa poti finaliza comanda este necesar macar o operatie.", @"Comanda need some operations",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (!CommonItem.DemoApp)
            {
                var selectedMecanics = new List <Mecanic>();

                foreach (var mecanic in Mecanics)
                {
                    if (mecanic.IsChecked)
                    {
                        selectedMecanics.Add(_clientMecanics.First(x => x.Id.Equals(mecanic.Item.Id)));
                    }
                }

                do
                {
                    using (var autoApi = new AutoServiceClient())
                    {
                        var response = autoApi.AddMecanics(selectedMecanics, _detaliuComanda);
                        if (response)
                        {
                            break;
                        }

                        userResponse = MessageBox.Show(
                            @"Ups.. change could not be done.  Try again ?",
                            @"Something went wrong",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Error);

                        if (userResponse == DialogResult.No)
                        {
                            break;
                        }
                    }
                }while (userResponse == DialogResult.Yes);
            }

            CommonItem.PageInstent.Clear();
            CommonItem.GetFrame().NavigationService.Navigate(new Dashboard());
        }
Esempio n. 4
0
        private void BuildOperatie()
        {
            DialogResult userResponse;

            var operatie = new Operatie()
            {
                Id           = Guid.NewGuid(),
                Denumire     = _addOperationTextBox.Text,
                TimpExecutie = decimal.Parse(_addTimeTextBox.Text)
            };

            if (!CommonItem.DemoApp)
            {
                do
                {
                    using (var autoApi = new AutoServiceClient())
                    {
                        var response = autoApi.AddOperatie(operatie, _detaliuComanda);
                        if (response)
                        {
                            break;
                        }

                        userResponse = MessageBox.Show(
                            @"Ups.. change could not be done.  Try again ?",
                            @"Something went wrong",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Error);

                        if (userResponse == DialogResult.No)
                        {
                            break;
                        }
                    }
                }while (userResponse == DialogResult.Yes);
            }

            Operations.Add(
                new SelectableViewModel <Operatie>
            {
                Item = new Operatie()
                {
                    Denumire = operatie.Denumire, TimpExecutie = operatie.TimpExecutie
                }
            });
        }
Esempio n. 5
0
        public Entities.Onderhoudsopdracht OnderhoudsOpdrachtUpdate(Entities.Onderhoudsopdracht onderhoudsopdracht)
        {
            using (IAutoServiceClient agent = new AutoServiceClient())
            {
                agent.BaseUri = new Uri("http://jomaya-autoservice/");
                //agent.BaseUri = new Uri("http://localhost:5003/");
                var result = agent.PutUpdateOnderhoudsopdracht(ObjectMapper.ConvertOnderhoudsOpdracht(onderhoudsopdracht));

                if (result is AutoService.Models.Onderhoudsopdracht)
                {
                    return(ObjectMapper.ConvertOnderhoudsOpdracht(result as AutoService.Models.Onderhoudsopdracht));
                }
                else
                {
                    throw new InvalidOperationException("Een fout is opgetreden bij de MicroService, " + (result as ErrorMessage).FoutMelding);
                }
            }
        }
Esempio n. 6
0
        public Entities.Auto AutoInvoeren(Entities.Auto auto)
        {
            using (IAutoServiceClient agent = new AutoServiceClient())
            {
                agent.BaseUri = new Uri("http://jomaya-autoservice/");
                //agent.BaseUri = new Uri("http://localhost:5003/");
                var result = agent.PostCreateAuto(ObjectMapper.ConvertAuto(auto));

                if (result is AutoService.Models.Auto)
                {
                    return(ObjectMapper.ConvertAuto(result as AutoService.Models.Auto));
                }
                else
                {
                    throw new InvalidOperationException("Een fout is opgetreden bij de MicroService, " + result.ToString());
                }
            }
        }
Esempio n. 7
0
        private void AddOperationButtonClick(object sender, RoutedEventArgs e)
        {
            BuildComanda();

            if (!CommonItem.DemoApp)
            {
                using (var autoApi = new AutoServiceClient())
                {
                    try
                    {
                        var response = autoApi.CreateDetaliuComanda(_detaliuComanda);

                        if (!response)
                        {
                            return;
                        }

                        if (!CommonItem.PageInstent.OfType <NewOperatiePage>().Any())
                        {
                            CommonItem.PageInstent.Add(new NewOperatiePage(_detaliuComanda));
                        }

                        CommonItem.GetFrame().NavigationService
                        .Navigate(CommonItem.PageInstent.OfType <NewOperatiePage>().First());
                        CommonItem.GetTextBox().Text = "ADD OPERATIONS";
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.ToString());
                    }
                }
            }
            else
            {
                if (!CommonItem.PageInstent.OfType <NewOperatiePage>().Any())
                {
                    CommonItem.PageInstent.Add(new NewOperatiePage(_detaliuComanda));
                }

                CommonItem.GetFrame().NavigationService
                .Navigate(CommonItem.PageInstent.OfType <NewOperatiePage>().First());
                CommonItem.GetTextBox().Text = "ADD OPERATIONS";
            }
        }
Esempio n. 8
0
 private void CustomInitialization()
 {
     try
     {
         using (var _autoApi = new AutoServiceClient())
         {
             var checkConnection = _autoApi.GetAvailabelMecanics().Count;
         }
     }
     catch (Exception e)
     {
         if (e.Message.Contains("no endpoint listening"))
         {
             CommonItem.DemoApp = true;
             CommonItem.SetFrame(ref _mainPanelFrame);
             CommonItem.SetTextBox(ref _pageName);
             MessageBox.Show("Serviciul Host WCF nu raspunde, aplicatia ruleaza in modul DEMO.");
         }
     }
 }
Esempio n. 9
0
        public void DashBoardInit()
        {
            this.FontFamily = new FontFamily("Champagne &amp; Limousines");
            if (!CommonItem.DemoApp)
            {
                using (_autoApi = new AutoServiceClient())
                {
                    this._dashboardMecanicAvail.Text = _autoApi.GetAvailabelMecanics().Count().ToString();
                    this._dashboardMecanicInfo.Text  =
                        $"Total of {_autoApi.GetAllMecanics().Count().ToString()} mechanics";

                    this._dashboardComenzi.Text     = _autoApi.GetAllOrders().Count().ToString();
                    this._dashboardComenziInfo.Text =
                        $"{_autoApi.GetAllDoneOrders().Count().ToString()} orders completed";

                    this._dashboardOperatii.Text     = _autoApi.GetAllOperations().Count().ToString();
                    this._dashboardOperatiiInfo.Text =
                        $"Total executing time is {_autoApi.GetOperationsTotalTime().ToString()}";
                }
            }
        }