protected override void OnCreate(Bundle bundle)
        {
            AndroidEnvironment.UnhandledExceptionRaiser += OnUnhandledEception;
            TaskScheduler.UnobservedTaskException       += OnUnhandledTaskException;

            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            Hub.Navigator = new AndroidNavigator(this);

            var vm = new TimesheetsViewModel(Hub.ApiClient, Hub.Navigator);

            ListView.Bind(this, vm.Timesheets, t => t.Name);
            ListView.BindItemSelected(vm.Timesheets, vm.TimesheetSelectedCommand);
            FindViewById <Button>(Resource.Id.refreshItems).Bind(vm.Timesheets.RefreshCommand);

            //Initiate the OAuth2 authentication process:
            var authenticator = new Xamarin.Auth.WindowsAzureOAuth2Authenticator(
                "https://login.windows.net/<your tenant id>",
                "<client app id>",
                "<api / resource uri>",
                new Uri("<client redirect uri>"));

            authenticator.Completed += AuthenticatorOnCompleted;

            var activity = authenticator.GetUI(this);

            StartActivity(activity);
        }
예제 #2
0
        public TimesheetView()
        {
            InitializeComponent();

            _viewModel = DataContext as TimesheetsViewModel;
            _viewModel.OnSelectFirstDayInMonth += scrollToFirstDayInMonth;
            _viewModel.OnSelectToday           += scrollToSelectedDay;
        }
예제 #3
0
        void HandleCompleted(object sender, Xamarin.Auth.AuthenticatorCompletedEventArgs e)
        {
            base.DismissViewController(true, null);

            if (e.IsAuthenticated)
            {
                Hub.ApiClient.TokenProvider = e.Account;
            }

            _vm = new TimesheetsViewModel(Hub.ApiClient, Hub.Navigator);
            this.timesheetList.Bind(_vm.Timesheets, t => t.Name, _vm.TimesheetSelectedCommand);
            this.refreshTimesheets.Bind(_vm.Timesheets.RefreshCommand);
        }
예제 #4
0
        private void MyNotifyIcon_TrayMouseDoubleClick(object sender, RoutedEventArgs e)
        {
            if (Visibility == Visibility.Hidden)
            {
                Show();

                // hack for focus the last selected day when the mainwindow starts from hidden state
                TimesheetsViewModel timesheetVM = SimpleIoc.Default.GetInstance <TimesheetsViewModel>();
                timesheetVM.OnSelectToday?.Invoke(timesheetVM.SelectedWorkingDay);
            }

            if (WindowState == WindowState.Minimized)
            {
                WindowState = WindowState.Normal;
            }
        }
        // GET: Timesheets
        public ActionResult Index()
        {
            List <TimesheetsViewModel> model = new List <TimesheetsViewModel>();

            TimesheetMobileEntities entities = new TimesheetMobileEntities();

            try
            {
                List <Timesheet> timesheets = entities.Timesheet.ToList();

                // muodostetaan näkymämalli tietokannan rivien pohjalta
                foreach (Timesheet timesheet in timesheets)
                {
                    TimesheetsViewModel view = new TimesheetsViewModel();
                    view.Id_Timesheet = timesheet.Id_Timesheet;
                    //view.Id_Customer = timesheet.Customers.Id_Customer;
                    //view.Id_Contractor = timesheet.Contractors.Id_Contractor;
                    //view.Id_Employee = timesheet.Id_Employee;
                    view.Id_WorkAssignment = timesheet.WorkAssignments.Id_WorkAssignment;
                    view.StartTime         = timesheet.StartTime.GetValueOrDefault();
                    view.StopTime          = timesheet.StopTime.GetValueOrDefault();
                    view.Comments          = timesheet.Comments;
                    view.WorkComplete      = timesheet.WorkComplete;
                    view.CreatedAt         = timesheet.CreatedAt.GetValueOrDefault();
                    view.LastModifiedAt    = timesheet.LastModifiedAt.GetValueOrDefault();
                    view.DeletedAt_        = timesheet.DeletedAt;
                    view.Active            = timesheet.Active;


                    view.FirstName = timesheet.Employees?.FirstName;
                    view.LastName  = timesheet.Employees?.LastName;



                    model.Add(view);
                }
            }
            finally
            {
                entities.Dispose();
            }



            return(View(model));
        }