예제 #1
0
        private Task SaveNewVacationAsync(VacationCellViewModel vacation)
        {
            vacation.Id = Guid.NewGuid().ToString();

            _vacations.Add(vacation);

            return(Task.CompletedTask);
        }
        public async Task UpsertVacationAsync([NotNull] VacationCellViewModel vacationViewModel, CancellationToken token = default)
        {
            token.ThrowIfCancellationRequested();

            var vacationDto = vacationViewModel.ToVacationDto();

            await _vacationApi.UpsertVacationAsync(vacationDto, token);
        }
예제 #3
0
        public async Task UpsertVacationAsync(VacationCellViewModel vacationViewModel, CancellationToken token = default)
        {
            if (vacationViewModel.Id == Guid.Empty.ToString())
            {
                await SaveNewVacationAsync(vacationViewModel);

                return;
            }

            await UpdateVacationAsync(vacationViewModel);
        }
예제 #4
0
        public static VacationCellViewModel ToVacationCellViewModel(this VacationDto vacationDto)
        {
            var vacationViewModel = new VacationCellViewModel
            {
                Id     = vacationDto.Id,
                Start  = vacationDto.Start,
                End    = vacationDto.End,
                Status = vacationDto.VacationStatus,
                Type   = vacationDto.VacationType
            };

            return(vacationViewModel);
        }
예제 #5
0
        public static VacationDto ToVacationDto(this VacationCellViewModel viewModel)
        {
            var vacationDto = new VacationDto
            {
                Id             = viewModel.Id,
                Start          = viewModel.Start,
                End            = viewModel.End,
                VacationStatus = viewModel.Status,
                CreatedBy      = "string",
                VacationType   = viewModel.Type
            };

            return(vacationDto);
        }
예제 #6
0
        private static Task UpdateVacationAsync(VacationCellViewModel vacation)
        {
            int index = -1;

            for (var i = 0; i < _vacations.Count; i++)
            {
                if (_vacations[i].Id == vacation.Id)
                {
                    index = i;
                    break;
                }
            }

            if (index != -1)
            {
                _vacations[index] = vacation;
            }

            return(Task.CompletedTask);
        }