//show the details page after we click on a service order in the list
        protected async void ShowDetailPage(ServiceOrderListViewModel.ServiceOrderListItemViewModel itemViewModel)
        {
            var detailVm = new ServiceOrderDetailViewModel(this);

            if (await detailVm.LoadFromListItem(itemViewModel))
            {
                await Navigation.PushAsync(new ServiceOrderDetailPage {
                    BindingContext = detailVm,
                });
            }
        }
Beispiel #2
0
//		private ServiceOrderListViewModel.ServiceOrderListItemViewModel _listItem;

        public async Task <bool> LoadFromListItem(ServiceOrderListViewModel.ServiceOrderListItemViewModel vm)
        {
            var result = false;

            await _app.WithContext(async context => {
                if (null != vm.ServcieOrderSearchResult)
                {
                    ServiceOrder = await context.Online.EnosixServiceOrderRepository.Get(vm.ServcieOrderSearchResult);
                }

                if (null != vm.Timesheet)
                {
                    // Try and lock the record
                    if (await context.Online.EnosixTimesheetRepository.Lock(vm.Timesheet, (locked) => { TimeSheet = locked; }))
                    {
                        EditMode = true;
                        _locked  = true;
                    }
                    else
                    {
                        EditMode  = false;
                        TimeSheet = await context.Online.EnosixTimesheetRepository.Get(vm.Timesheet);
                    }
                }

                if (null == TimeSheet)
                {
                    TimeSheet = await context.Online.EnosixTimesheetRepository.Initialize(
                        new EnosixTimesheet()
                    {
                        Username = _app.UserName,
                        DateFrom = Week,
                        DateTo   = vm.Week.AddDays(7),
                    }
                        );

                    EditMode = true;
                }

                result = true;
            });

            //sets the timesheet to the current week
            this.Week = vm.Week;



            TimesheetUpdated();

            return(result);
        }