Exemple #1
0
        private void SetWorkingTimes(object sender)
        {
            if (!(sender is RequestItemViewModel))
            {
                return;
            }
            var requestModel = sender as RequestItemViewModel;

            if (!requestModel.RequestId.HasValue)
            {
                return;
            }
            var model = new SetWorkingTimesDialogViewModel(FromTime, ToTime);
            var view  = new SetWorkingTimesDialog();

            model.SetView(view);
            view.Owner       = _view;
            view.DataContext = model;
            if (view.ShowDialog() == true)
            {
                var fromTime = DateTime.ParseExact($"01.01.0001 {model.FromHour}:{model.FromMinute}", "dd.MM.yyyy HH:mm", null);
                var toTime   = DateTime.ParseExact($"01.01.0001 {model.ToHour}:{model.ToMinute}", "dd.MM.yyyy HH:mm", null);
                if (toTime < fromTime)
                {
                    toTime = toTime.AddDays(1);
                }
                _requestService.SetRequestWorkingTimes(requestModel.RequestId.Value, fromTime, toTime, AppSettings.CurrentUser.Id);
            }
        }