public async Task <bool> UpdateOrCreateVacationInRest(VacationsViewModel viewModel, VacationInfoModel vacation) { VacationUpdateResponce responce = null; try { responce = await _vacationsDataService.UpdateOrCreateVacationsRest(vacation); } catch (AggregateException e) { viewModel.ErrorMessage = e.InnerExceptions[0].Data["message"].ToString(); } catch (Exception ex) { viewModel.ErrorMessage = ex.Message; } if (responce.LoginSuccess) { viewModel.State = UserState.Authorized; viewModel.ErrorMessage = String.Empty; } else { viewModel.State = UserState.Unauthorized; viewModel.ErrorMessage = responce.ErrorMessage; } return(await Helper.Complete(responce.LoginSuccess)); }
public async Task <bool> DeleteVacation(VacationsViewModel viewModel, VTSModel vacation) { VacationUpdateResponce responce = new VacationUpdateResponce(0, true, string.Empty); if (viewModel.IsOnlineMode) { try { responce = await _vacationsDataService.DeleteVacationInRest(vacation); } catch (AggregateException e) { viewModel.ErrorMessage = e.InnerExceptions[0].Data["message"].ToString(); return(false); } catch (Exception ex) { viewModel.ErrorMessage = ex.Message; return(false); } } if (responce.LoginSuccess) { viewModel.State = UserState.Authorized; viewModel.ErrorMessage = String.Empty; } else { viewModel.State = UserState.Unauthorized; viewModel.ErrorMessage = responce.ErrorMessage; } await _vacationsDataService.DeleteVacationsInSql(vacation); return(await Helper.Complete(responce.LoginSuccess)); }