public PolicyService(HttpClient httpClient, IODataClient oDataClient, IInitialDataService initialDataService, ILicenseHelper licenseHelper) : base(oDataClient) { _oDataClient = oDataClient; _httpClient = httpClient; _initialDataService = initialDataService; _licenseHelper = licenseHelper; }
public EvaluationRequestLostDetailViewModel( IUserDialogs userDialogs, ILicenseHelper licenseHelper, ISanaapAppTranslateService translateService, IEvlRequestValidator evlRequestValidator, IInitialDataService initialDataService, IPageDialogService dialogService) { _initialDataService = initialDataService; _userDialogs = userDialogs; _licenseHelper = licenseHelper; GoBack = new BitDelegateCommand(async() => { await NavigationService.GoBackAsync(); }); GoToNextLevel = new BitDelegateCommand(async() => { requestCancellationTokenSource?.Cancel(); requestCancellationTokenSource = new CancellationTokenSource(); using (userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: requestCancellationTokenSource.Cancel)) { if (SelectedCar == null) { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.CarIsNull, ConstantStrings.Ok); return; } if (SelectedAlphabet == null) { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.NumberPlateIsNotValid, ConstantStrings.Ok); return; } Request.LostCarId = SelectedCar.PrmID; LostLicense.Alphabet = SelectedAlphabet.Name; if (licenseHelper.ConvertToPlateNumber(LostLicense, out string licensePlate)) { Request.LostPlateNumber = licensePlate; } else { return; } if (!evlRequestValidator.IsLostDetailValid(Request, out string message)) { await dialogService.DisplayAlertAsync(string.Empty, translateService.Translate(message), ConstantStrings.Ok); return; } await NavigationService.NavigateAsync(nameof(EvaluationRequestDescriptionView), new NavigationParameters { { nameof(Request), Request } }); } }); }
public EvlRequestWaitViewModel( IODataClient odataClient, IEvlRequestService evlRequestService, IDeviceService deviceService, IODataClient oDataClient, HttpClient httpClient, IDateTimeUtils dateTimeUtils, IInitialDataService initialDataService, IPageDialogService pageDialogService) { _odataClient = odataClient; _evlRequestService = evlRequestService; _pageDialogService = pageDialogService; _initialDataService = initialDataService; _httpClient = httpClient; _dateTimeUtils = dateTimeUtils; GoToMain = new BitDelegateCommand(async() => { await NavigationService.NavigateAsync($"/{nameof(NavigationPage)}/{nameof(MainMenuView)}"); }); Call = new BitDelegateCommand(async() => { deviceService.OpenUri(new Uri("tel://" + ExpertMobileNo + "")); }); //RatingValueChanged = new BitDelegateCommand<int>(async (value) => //{ // await _pageDialogService.DisplayAlertAsync("", "RatingValueChanged : " + value.ToString(), ErrorMessages.Ok); //}); }
public LisContext(string connectionString, ISystemLogger logger, IInitialDataService initialDataService) : base(connectionString) { _logger = logger; _InitialDataService = initialDataService; Database.Log = log => Debug.WriteLine(log); this.Database.CommandTimeout = 0; Configuration.ProxyCreationEnabled = true; Configuration.LazyLoadingEnabled = true; }
public MainMenuViewModel( ISecurityService securityService, IDeviceService deviceService, IUserDialogs userDialogs, HttpClient httpClient, IInitialDataService initialDataService) { _userDialogs = userDialogs; _httpClient = httpClient; _initialDataService = initialDataService; GoToEvalutionRequestMenu = new BitDelegateCommand(async() => { await NavigationService.NavigateAsync(nameof(EvaluationRequestMenuView)); }); }
public ContentListViewModel(IODataClient oDataClient, IUserDialogs userDialogs, INewsService newsService, IInitialDataService initialDataService, IEventAggregator eventAggregator, IPageDialogService dialogService) { _oDataClient = oDataClient; _userDialogs = userDialogs; _newsService = newsService; _initialDataService = initialDataService; ShowContent = new BitDelegateCommand <NewsItemSource>(async(content) => { INavigationParameters parameters = new NavigationParameters(); parameters.Add("NewsId", content.NewsID); await NavigationService.NavigateAsync(nameof(ShowContentView), parameters); }); FilterContent = new BitDelegateCommand(async() => { FilterDto.Month = SelectedMonth?.Number; FilterDto.Year = SelectedYear?.Number; if (FilterDto.Month != null || FilterDto.Year != null) { if (FilterDto.Month == null || FilterDto.Year == null) { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.NewsFilterNotValid, ConstantStrings.Ok); SelectedYear = null; SelectedMonth = null; return; } } contentCancellationTokenSource?.Cancel(); contentCancellationTokenSource = new CancellationTokenSource(); using (_userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: contentCancellationTokenSource.Cancel)) { await loadContents(FilterDto); } eventAggregator.GetEvent <OpenNewsFilterPopupEvent>().Publish(new OpenNewsFilterPopupEvent()); FilterDto = new FilterNewsDto(); SelectedYear = null; SelectedMonth = null; }); OpenFilterPopup = new BitDelegateCommand(async() => { eventAggregator.GetEvent <OpenNewsFilterPopupEvent>().Publish(new OpenNewsFilterPopupEvent()); }); }
public EvaluationRequestDescriptionViewModel( IDateHelper dateHelper, ISanaapAppTranslateService translateService, IInitialDataService initialDataService, IPageDialogService dialogService, IEvlRequestValidator evlRequestValidator) { _dateHelper = dateHelper; _dialogService = dialogService; _initialDataService = initialDataService; GoToNextLevel = new BitDelegateCommand(async() => { if (SelectedDate == null) { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.AccidentDateIsNull, ConstantStrings.Ok); return; } Request.AccidentDate = new DateTimeOffset((DateTime)SelectedDate, DateTimeOffset.Now.Offset); if (SelectedAccidentReason != null) { Request.AccidentReason = SelectedAccidentReason.Name; } await NavigationService.NavigateAsync(nameof(EvaluationRequestMapView), new NavigationParameters { { nameof(Request), Request } }); }); GoBack = new BitDelegateCommand(async() => { await NavigationService.GoBackAsync(); }); }
public EvaluationRequestFilesViewModel(IMedia media, IODataClient oDataClient, IUserDialogs userDialogs, IInitialDataService initialDataService, IPageDialogService dialogService, IClientAppProfile clientApp, IEventAggregator eventAggregator, ISecurityService securityService) { _oDataClient = oDataClient; _userDialogs = userDialogs; _initialDataService = initialDataService; TakePhoto = new BitDelegateCommand <EvlRequestFileItemSource>(async(file) => { //500 is ID for More pictures if (file.TypeId == 500) { Files.Add(new EvlRequestFileItemSource { TypeId = file.TypeId, TypeName = file.TypeName, Image = file.Image }); } _fileIndex = Files.IndexOf(file); eventAggregator.GetEvent <TakePhotoEvent>().Publish(new TakePhotoEvent()); }); GoBack = new BitDelegateCommand(async() => { await NavigationService.GoBackAsync(); }); OpenCamera = new BitDelegateCommand(async() => { eventAggregator.GetEvent <TakePhotoEvent>().Publish(new TakePhotoEvent()); MediaFile mediaFile = await media.TakePhotoAsync(new StoreCameraMediaOptions { Directory = "Sanaap", SaveToAlbum = true, CompressionQuality = 25, CustomPhotoSize = 30, PhotoSize = PhotoSize.Medium, MaxWidthHeight = 2000, AllowCropping = true, DefaultCamera = CameraDevice.Rear }); if (mediaFile != null) { using (MemoryStream ms = new MemoryStream()) { mediaFile.GetStream().CopyTo(ms); Files[_fileIndex].Data = ms.ToArray(); } Files[_fileIndex].Image = ImageSource.FromStream(() => mediaFile.GetStream()); Files[_fileIndex].HasImage = true; } else { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.PictureIsNull, ConstantStrings.Ok); } }); Gallery = new BitDelegateCommand(async() => { eventAggregator.GetEvent <TakePhotoEvent>().Publish(new TakePhotoEvent()); MediaFile mediaFile = await media.PickPhotoAsync(new PickMediaOptions { PhotoSize = PhotoSize.Medium, CompressionQuality = 25, }); if (mediaFile != null) { using (MemoryStream ms = new MemoryStream()) { mediaFile.GetStream().CopyTo(ms); Files[_fileIndex].Data = ms.ToArray(); } Files[_fileIndex].Image = ImageSource.FromStream(() => mediaFile.GetStream()); Files[_fileIndex].HasImage = true; } else { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.PictureIsNull, ConstantStrings.Ok); } }); Submit = new BitDelegateCommand(async() => { if (Files.Any(f => f.IsRequired && f.HasImage == false)) { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.PictureIsRequired, ConstantStrings.Ok); return; } if (await dialogService.DisplayAlertAsync(string.Empty, ConstantStrings.AreYouSure, ConstantStrings.Yes, ConstantStrings.No)) { using (HttpClient http = new HttpClient()) { http.BaseAddress = clientApp.HostUri; http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", (await securityService.GetCurrentTokenAsync()).access_token); using (userDialogs.Loading(ConstantStrings.SendingRequestAndPictures)) { MultipartFormDataContent submitEvlRequestContents = new MultipartFormDataContent { new StringContent(JsonConvert.SerializeObject(Request), Encoding.UTF8, "application/json") }; foreach (EvlRequestFileDto file in Files.Where(f => f.Data != null)) { submitEvlRequestContents.Add(new ByteArrayContent(file.Data), file.TypeId.ToString(), file.TypeId.ToString()); } HttpRequestMessage submitEvlRequest = new HttpRequestMessage(HttpMethod.Post, "api/evl-requests/submit-evl-request") { Content = submitEvlRequestContents }; HttpResponseMessage submitEvlRequestExpertResponse = await http.SendAsync(submitEvlRequest); submitEvlRequestExpertResponse.EnsureSuccessStatusCode(); Request = JsonConvert.DeserializeObject <EvlRequestItemSource>(await submitEvlRequestExpertResponse.Content.ReadAsStringAsync()); await NavigationService.NavigateAsync(nameof(EvaluationRequestWaitView), new NavigationParameters { { nameof(Request), Request } }); } } } }); OpenPhoto = new BitDelegateCommand <EvlRequestFileItemSource>(async(image) => { await NavigationService.NavigateAsync(nameof(OpenImagePopup), new NavigationParameters { { nameof(image.Image), image.Image } }); }); DeletePhoto = new BitDelegateCommand <EvlRequestFileItemSource>(async(image) => { if (image.HasImage == false) { return; } if (await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.AreYouSureToDelete, ConstantStrings.Yes, ConstantStrings.No)) { image.Image = null; image.HasImage = false; await NavigationService.GoBackAsync(); } }); }
public EvaluationRequestMenuViewModel(IEventAggregator eventAggregator, IPolicyService policyService, IUserDialogs userDialogs, IInitialDataService initialDataService, IPageDialogService dialogService) { _policyService = policyService; _userDialogs = userDialogs; _eventAggregator = eventAggregator; EvlRequestBadane = new BitDelegateCommand(async() => { await NavigationService.NavigateAsync(nameof(EvaluationRequestDetailView), new NavigationParameters { { nameof(InsuranceType), InsuranceType.Badane } }); }); EvlRequestSales = new BitDelegateCommand(async() => { await NavigationService.NavigateAsync(nameof(EvaluationRequestDetailView), new NavigationParameters { { nameof(InsuranceType), InsuranceType.Sales } }); }); #region insurancePopup SelectPolicy = new BitDelegateCommand <PolicyItemSource>(async(policy) => { using (_userDialogs.Loading(ConstantStrings.Loading)) { CustomerDto customer = await initialDataService.GetCurrentUserInfo(); eventAggregator.GetEvent <OpenInsurancePopupEvent>().Publish(new OpenInsurancePopupEvent()); _request.InsurerNo = policy.InsurerNo; _request.InsurerId = policy.InsurerId; _request.CarId = policy.CarId; _request.PlateNumber = policy.PlateNumber; _request.OwnerFirstName = customer.FirstName; _request.OwnerLastName = customer.LastName; await NavigationService.NavigateAsync(nameof(EvaluationRequestDetailView), new NavigationParameters { { "Request", _request }, }); } }); #endregion }
public ConsultationContext(string connectionString, ICommonLog logger, IInitialDataService initialDataService) : this(connectionString, logger) { _InitialDataService = initialDataService; }
public CreateInsurancePolicyViewModel( IUserDialogs userDialogs, HttpClient httpClient, IInitialDataService initialDataService, IODataClient oDataClient, IInsuranceValidator insuranceValidator, IPageDialogService dialogService, IPolicyService policyService, ILicenseHelper licenseHelper, IDateHelper dateHelper, ISanaapAppTranslateService translateService ) { _oDataClient = oDataClient; _userDialogs = userDialogs; _initialDataService = initialDataService; _licenseHelper = licenseHelper; _dialogService = dialogService; _dateHelper = dateHelper; foreach (InsuranceType item in (InsuranceType[])Enum.GetValues(typeof(InsuranceType))) { InsuranceTypes.Add(new InsuranceTypeItemSource { InsuranceType = item, InsuranceTypeName = EnumHelper <InsuranceType> .GetDisplayValue(item) }); } SelectedInsuranceType = InsuranceTypes[0]; Submit = new BitDelegateCommand(async() => { insuranceCancellationTokenSource?.Cancel(); insuranceCancellationTokenSource = new CancellationTokenSource(); using (_userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: insuranceCancellationTokenSource.Cancel)) { if (SelectedCar == null) { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.CarIsNull, ConstantStrings.Ok); return; } if (SelectedInsurer == null) { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.InsurerIsNull, ConstantStrings.Ok); return; } if (SelectedAlphabet == null) { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.NumberPlateIsNotValid, ConstantStrings.Ok); return; } if (SelectedColor == null) { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.ColorIsNull, ConstantStrings.Ok); return; } if (SelectedDate == null) { await dialogService.DisplayAlertAsync(ConstantStrings.Error, ConstantStrings.ExpirationDateIsNotValid, ConstantStrings.Ok); return; } License.Alphabet = SelectedAlphabet.Name; Policy.ExpirationDate = new DateTimeOffset((DateTime)SelectedDate, DateTimeOffset.Now.Offset); if (licenseHelper.ConvertToPlateNumber(License, out string licensePlate)) { Policy.PlateNumber = licensePlate; } else { return; } if (!insuranceValidator.IsValid(Policy, out string errorMessage)) { await dialogService.DisplayAlertAsync(string.Empty, translateService.Translate(errorMessage), ConstantStrings.Ok); return; } Policy.ColorId = SelectedColor.PrmID; Policy.CarId = SelectedCar.PrmID; Policy.InsuranceType = SelectedInsuranceType.InsuranceType; Policy.InsurerId = SelectedInsurer.ID; policyCancellationTokenSource?.Cancel(); policyCancellationTokenSource = new CancellationTokenSource(); using (userDialogs.Loading(ConstantStrings.Loading, cancelText: ConstantStrings.Loading_Cancel, onCancel: policyCancellationTokenSource.Cancel)) { if (method == EditMethod.Create) { await policyService.AddAsync(Policy); } else { await policyService.UpdateAsync(Policy); } } } await dialogService.DisplayAlertAsync(string.Empty, ConstantStrings.SuccessfulProcess, ConstantStrings.Ok); await NavigationService.GoBackAsync(); }); SelectInsurer = new BitDelegateCommand <InsurersItemSource>(async(parameter) => { foreach (InsurersItemSource insurer in Insurers) { insurer.IsSelected = false; } parameter.IsSelected = true; SelectedInsurer = parameter; }); }