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); }
public async Task UpsertVacationAsync(VacationCellViewModel vacationViewModel, CancellationToken token = default) { if (vacationViewModel.Id == Guid.Empty.ToString()) { await SaveNewVacationAsync(vacationViewModel); return; } await UpdateVacationAsync(vacationViewModel); }
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); }
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); }
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); }