private async Task <AgencyFranchiseMap> TransformAndMapAgency(AgencyResponse clearCareAgencyResult) { var franchiseMap = new AgencyFranchiseMap { clear_care_agency = clearCareAgencyResult.id }; string subdomainFranchise = null; var containsOnOrMoreDigits = _oneOrMoreDigitsRegex.Match(clearCareAgencyResult.subdomain); if (containsOnOrMoreDigits.Success) { subdomainFranchise = containsOnOrMoreDigits.Value; } IList <LocationResponse> locations = new List <LocationResponse>(); if (!string.IsNullOrWhiteSpace(clearCareAgencyResult.locations)) { locations = await _resourceLoader.LoadAsync <LocationResponse>(clearCareAgencyResult.locations); } franchiseMap.franchise_numbers = GetFranchiseNumbers(subdomainFranchise, locations); return(franchiseMap); }
public AgencyResponse Delete(Guid identifier) { AgencyResponse response = new AgencyResponse(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); SqliteCommand insertCommand = new SqliteCommand(); insertCommand.Connection = db; //Use parameterized query to prevent SQL injection attacks insertCommand.CommandText = "DELETE FROM Agencies WHERE Identifier = @Identifier"; insertCommand.Parameters.AddWithValue("@Identifier", identifier); try { insertCommand.ExecuteNonQuery(); } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; return(response); } db.Close(); response.Success = true; return(response); } }
public AgencyResponse Create(AgencyViewModel Agency) { AgencyResponse response = new AgencyResponse(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); SqliteCommand insertCommand = db.CreateCommand(); insertCommand.CommandText = SqlCommandInsertPart; try { insertCommand = AddCreateParameters(insertCommand, Agency); insertCommand.ExecuteNonQuery(); } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; return(response); } db.Close(); response.Success = true; return(response); } }
private void ProcessAgengyData(AgencyResponse item) { City city = ValidateCity(item.City); State state = ValidateState(item.State); Status status = ValidateStatus(item.Status); Agency agency = GetAgencyData(item, city, state, status); ProcessAgengy(agency); }
private Agency GetAgencyData(AgencyResponse item, City city, State state, Status status) { Agency agency = new Agency(); agency.Name = item.Name; agency.AgencyId = item.Id; agency.CityId = city.CityId; agency.StateId = state.StateId; agency.StatusId = status.StatusId; return(agency); }
public AgencyResponse Create(AgencyViewModel Agency) { AgencyResponse response = new AgencyResponse(); try { response = WpfApiHandler.SendToApi <AgencyViewModel, AgencyResponse>(Agency, "Create"); } catch (Exception ex) { response.Agency = new AgencyViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public AgencyResponse Delete(Guid identifier) { AgencyResponse response = new AgencyResponse(); try { AgencyViewModel re = new AgencyViewModel(); re.Identifier = identifier; response = WpfApiHandler.SendToApi <AgencyViewModel, AgencyResponse>(re, "Delete"); } catch (Exception ex) { response.Agency = new AgencyViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public JsonResult Delete([FromBody] AgencyViewModel remedy) { AgencyResponse response = new AgencyResponse(); try { response = this.AgencyService.Delete(remedy.Identifier); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; Console.WriteLine(ex.Message); } return(Json(response, new Newtonsoft.Json.JsonSerializerSettings() { Formatting = Newtonsoft.Json.Formatting.Indented })); }
public AgencyResponse DeleteAll() { AgencyResponse response = new AgencyResponse(); try { using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); db.EnableExtensions(true); SqliteCommand insertCommand = new SqliteCommand(); insertCommand.Connection = db; //Use parameterized query to prevent SQL injection attacks insertCommand.CommandText = "DELETE FROM Agencies"; try { insertCommand.ExecuteNonQuery(); } catch (SqliteException error) { response.Success = false; response.Message = error.Message; MainWindow.ErrorMessage = error.Message; return(response); } db.Close(); } } catch (SqliteException error) { response.Success = false; response.Message = error.Message; return(response); } response.Success = true; return(response); }
public AgencyResponse Create(AgencyViewModel Agency) { AgencyResponse response = new AgencyResponse(); try { Agency addedAgency = unitOfWork.GetAgencyRepository().Create(Agency.ConvertToAgency()); unitOfWork.Save(); response.Agency = addedAgency.ConvertToAgencyViewModel(); response.Success = true; } catch (Exception ex) { response.Agency = new AgencyViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public AgencyResponse Delete(Guid identifier) { AgencyResponse response = new AgencyResponse(); try { Agency deletedAgency = unitOfWork.GetAgencyRepository().Delete(identifier); unitOfWork.Save(); response.Agency = deletedAgency.ConvertToAgencyViewModel(); response.Success = true; } catch (Exception ex) { response.Agency = new AgencyViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public AgencyResponse GetAgency(Guid identifier) { AgencyResponse response = new AgencyResponse(); AgencyViewModel Agency = new AgencyViewModel(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM Agencies " + "WHERE Identifier = @Identifier;", db); selectCommand.Parameters.AddWithValue("@Identifier", identifier); SqliteDataReader query = selectCommand.ExecuteReader(); if (query.Read()) { AgencyViewModel dbEntry = Read(query); Agency = dbEntry; } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.Agency = new AgencyViewModel(); return(response); } db.Close(); } response.Success = true; response.Agency = Agency; return(response); }
private void btnSave_Click(object sender, RoutedEventArgs e) { #region Validation //if (CurrentAgency.Code == null) //{ // MainWindow.WarningMessage = "Obavezno polje: Šifra"; // return; //} if (String.IsNullOrEmpty(CurrentAgency.Name)) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Naziv_delatnosti")); return; } if (CurrentAgency.Country == null) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Ime_drzave")); return; } if (CurrentAgency.Sector == null) { MainWindow.WarningMessage = ((string)Application.Current.FindResource("Obavezno_poljeDvotačka_Naziv_sektora")); return; } #endregion Thread th = new Thread(() => { SaveButtonContent = ((string)Application.Current.FindResource("Čuvanje_u_tokuTriTacke")); SaveButtonEnabled = false; CurrentAgency.IsSynced = false; CurrentAgency.Company = new CompanyViewModel() { Id = MainWindow.CurrentCompanyId }; CurrentAgency.CreatedBy = new UserViewModel() { Id = MainWindow.CurrentUserId }; AgencyResponse response = AgencyService.Create(CurrentAgency); if (!response.Success) { MainWindow.ErrorMessage = ((string)Application.Current.FindResource("Greška_kod_čuvanja_na_serveruUzvičnik")); SaveButtonContent = ((string)Application.Current.FindResource("Sačuvaj")); SaveButtonEnabled = true; } if (response.Success) { MainWindow.SuccessMessage = ((string)Application.Current.FindResource("Podaci_su_uspešno_sačuvaniUzvičnik")); SaveButtonContent = ((string)Application.Current.FindResource("Sačuvaj")); SaveButtonEnabled = true; AgencyCreatedUpdated(); if (IsCreateProcess) { CurrentAgency = new AgencyViewModel(); CurrentAgency.Identifier = Guid.NewGuid(); Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { txtName.Focus(); }) ); } else { Application.Current.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(() => { if (IsPopup) { FlyoutHelper.CloseFlyoutPopup(this); } else { FlyoutHelper.CloseFlyout(this); } }) ); } } }); th.IsBackground = true; th.Start(); }