public void SaveInput(SupportFormModel jsonContent) { if (jsonContent.ID == 0) { _db.Insert(jsonContent); } }
public TransactionViewModel(INavService navService, INetworkService netService, IDatabaseService db, ICustomDialogService dialog) : base(navService, netService, db, dialog) { IsBusy = false; JsonContent = new SupportFormModel(); var location = DependencyService.Get <ILocationInterface>(); // DependencyService.Get<ILocationInterface>().InitialService(); }
public async Task ProcessSupportForm(string tid, string acquiringBank, string MerchantName, string MerchantNumber, string terminalType, string version, string terminalSerial, string purpose, string battery, string merchantAddress, string reason) { // int b = 0; if (string.IsNullOrEmpty(tid) ||// || string.IsNullOrEmpty(acquiringBank) string.IsNullOrEmpty(MerchantName) || string.IsNullOrEmpty(MerchantNumber) || string.IsNullOrEmpty(terminalType) || string.IsNullOrEmpty(version) || string.IsNullOrEmpty(terminalSerial) || string.IsNullOrEmpty(purpose) || string.IsNullOrEmpty(merchantAddress)) { _dialog.ShowToastMessage("Input all data", true); } else if (tid.Length != 8) { _dialog.ShowToastMessage("Invalid Terminal ID", true); } //else if (!int.TryParse(battery, out b)) //{ // _dialog.ShowToastMessage("Invalid Battery Level", true); //} // else if(b > 100) // _dialog.ShowToastMessage("Invalid Battery Level", true); else { JsonContent = new SupportFormModel() { SupportStaff = ServiceLocator.Current.GetInstance <IDatabaseService>().GetUserProfile().Email, TerminalID = tid, Purpose = reason, PosStatus = purpose, MerchantName = MerchantName, Version = version, TerminalType = terminalType, TerminalSerial = terminalSerial, MerchantMobile = MerchantNumber, AcquiringBank = acquiringBank, Battery = $"{battery}%", merchantAddress = merchantAddress, }; await ContinueTerminalStatus(); //_navigationService.NavigateTo(PageStrings.TerminalPage); } }
private async Task SendContent(SupportFormModel item) { try { if (item != null) { var _json = JObject.Parse(JsonConvert.SerializeObject(item).ToString()); if (App.IsConnected) { var content = await _networkService.PostAsync(_json, "URL"); if (content != null) { int result = (int)content["result"]; if (result == 1) { if (item.ID != 0) { _db.DeleteInput(item); } _dialog.ShowToastMessage("Data Submitted", true); _navigationService.NavigateTo(PageStrings.DashboardPage); } else { _db.SaveInput(item); _dialog.ShowToastMessage(content["message"].ToString(), true); } } } else { _db.SaveInput(item); _dialog.ShowToastMessage("You do not have internet connection. Your data will be summited later", true); } } } catch (Exception ex) { Utils.Utility.ShowDebug(ex); } }
public void DeleteInput(SupportFormModel jsonContent) { _db.Delete <SupportFormModel>(jsonContent.ID); }