Beispiel #1
0
        public void CreateMeeting_InputValidate_Failure_NoExistLabel()
        {
            var createMeetingValidation = new CreateMeetingValidation();
            var testMeetingLabels       = new ObservableCollection <MeetingLabelData>();

            var testMeetingDate      = DateTime.UtcNow;
            var testMeetingStartTime = new TimeSpan(10, 0, 0);
            var testMeetingEndTime   = new TimeSpan(11, 0, 0);

            var result = createMeetingValidation.InputValidate("testMeeting", testMeetingDate, testMeetingStartTime, testMeetingEndTime, "", testMeetingLabels);

            Assert.IsFalse(result.IsSuccessed);
            Assert.IsTrue(result.HasError);
            Assert.IsTrue(result.NoExistLabel);
        }
Beispiel #2
0
        public void CreateMeeting_InputValidate_Success()
        {
            var createMeetingValidation = new CreateMeetingValidation();
            var testMeetingLabels       = new ObservableCollection <MeetingLabelData>();
            var testMeetingLabel        = new MeetingLabelData(1, "test");

            testMeetingLabels.Add(testMeetingLabel);

            var testMeetingDate      = DateTime.UtcNow;
            var testMeetingStartTime = new TimeSpan(10, 0, 0);
            var testMeetingEndTime   = new TimeSpan(11, 0, 0);

            var result = createMeetingValidation.InputValidate("testMeeting", testMeetingDate, testMeetingStartTime, testMeetingEndTime, "MeetingSpace", testMeetingLabels);

            Assert.IsTrue(result.IsSuccessed);
            Assert.IsFalse(result.HasError);
        }
        public MeetingDataCreatePageViewModel(INavigationService navigationService) : base(navigationService)
        {
            _navigationService = navigationService;

            _restService           = new RestService();
            _applicationProperties = new ApplicationProperties();

            _createMeetingParam      = new CreateMeetingParam();
            _createMeetingLabelParam = new CreateMeetingLabelParam();

            _createMeetingValidation      = new CreateMeetingValidation();
            _createMeetingLabelValidation = new CreateMeetingLabelValidation();

            Labels = new ObservableCollection <MeetingLabelData>();


            //入力初期値
            InputMeetingDate = DateTime.UtcNow;

            CreateMeetingDataCommand = new DelegateCommand(async() =>

            {
                //会議情報入力値のバリデーション処理
                CreateMeetingParam = _createMeetingValidation.InputValidate(InputMeetingTitle, InputMeetingDate, InputMeetingStartTime, InputMeetingEndTime, InputMeetingLocation, Labels);

                //バリデーションエラーが存在すれば失敗で返す
                if (CreateMeetingParam.HasError == true)
                {
                    return;
                }

                //DateTimeとTimeSpanを結合
                var InputMeetingStartDateTime = InputMeetingDate + InputMeetingStartTime;
                var InputMeetingEndDateTime   = InputMeetingDate + InputMeetingEndTime;

                //userIdに対するidを取得
                var getUserParam = await _restService.GetUserDataAsync(UserConstants.OpenUserEndPoint, _applicationProperties.GetFromProperties <string>("userId"));

                //ユーザー取得時にエラーがあれば処理終了
                if (getUserParam.HasError == true)
                {
                    return;
                }

                //Json用のモデルを作成
                CreateMeetingData = new MeetingData();

                CreateMeetingData.Title         = InputMeetingTitle;
                CreateMeetingData.StartDatetime = InputMeetingStartDateTime;
                CreateMeetingData.EndDatetime   = InputMeetingEndDateTime;
                CreateMeetingData.Regular       = false;
                CreateMeetingData.Owner         = getUserParam.User.Id;
                CreateMeetingData.Location      = InputMeetingLocation;
                CreateMeetingData.IsVisible     = true;

                //会議作成APIのコール
                CreateMeetingParam = await _restService.CreateMeetingDataAsync(MeetingConstants.OpenMeetingEndPoint, CreateMeetingData, Labels);

                //会議作成が成功すればMeetingDataTopPageに遷移する
                if (CreateMeetingParam.IsSuccessed == true)
                {
                    await _navigationService.NavigateAsync("/NavigationPage/MeetingDataTopPage");
                }
            });

            //ラベル追加の際のコマンド
            CreateMeetingLabelCommand = new DelegateCommand(() =>
            {
                //作成するラベル名のバリデーション
                CreateMeetingLabelParam = _createMeetingLabelValidation.InputValidate(CreateLabelName);
                //ラベル作成に失敗すれば処理中断
                if (CreateMeetingLabelParam.HasError == true)
                {
                    return;
                }

                //リストにラベル情報を保持
                var label = new MeetingLabelData(CreateLabelName);
                Labels.Add(label);
                CreateLabelName = "";

                //ViewにおけるFrameの高さを大きくする
                LabelListViewHeight += 85;
            });

            NavigateMeetingDataTopPage = new DelegateCommand(() =>
            {
                //会議情報TOPページへ遷移
                _navigationService.NavigateAsync("/NavigationPage/MeetingDataTopPage");
            });
        }