public BusinessPartnerBankResponse SetStatusDeleted(Guid identifier) { BusinessPartnerBankResponse response = new BusinessPartnerBankResponse(); 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 = "UPDATE BusinessPartnerBanks SET ItemStatus = @ItemStatus WHERE Identifier = @Identifier"; insertCommand.Parameters.AddWithValue("@ItemStatus", ItemStatus.Deleted); insertCommand.Parameters.AddWithValue("@Identifier", identifier); try { insertCommand.ExecuteReader(); } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; return(response); } db.Close(); response.Success = true; return(response); } }
public BusinessPartnerBankResponse Create(BusinessPartnerBankViewModel businessPartnerBank) { BusinessPartnerBankResponse response = new BusinessPartnerBankResponse(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); SqliteCommand insertCommand = db.CreateCommand(); insertCommand.CommandText = SqlCommandInsertPart; try { insertCommand = AddCreateParameters(insertCommand, businessPartnerBank); 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 BusinessPartnerBankResponse Create(BusinessPartnerBankViewModel businessPartnerBankViewModel) { BusinessPartnerBankResponse response = new BusinessPartnerBankResponse(); try { response = WpfApiHandler.SendToApi <BusinessPartnerBankViewModel, BusinessPartnerBankResponse>(businessPartnerBankViewModel, "Create"); } catch (Exception ex) { response.BusinessPartnerBank = new BusinessPartnerBankViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public BusinessPartnerBankResponse Delete(Guid identifier) { BusinessPartnerBankResponse response = new BusinessPartnerBankResponse(); try { BusinessPartnerBankViewModel viewModel = new BusinessPartnerBankViewModel(); viewModel.Identifier = identifier; response = WpfApiHandler.SendToApi <BusinessPartnerBankViewModel, BusinessPartnerBankResponse>(viewModel, "Delete"); } catch (Exception ex) { response.BusinessPartnerBank = new BusinessPartnerBankViewModel(); response.Success = false; response.Message = ex.Message; } return(response); }
public BusinessPartnerBankResponse GetBusinessPartnerBank(Guid identifier) { BusinessPartnerBankResponse response = new BusinessPartnerBankResponse(); BusinessPartnerBankViewModel businessPartnerBank = new BusinessPartnerBankViewModel(); using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db")) { db.Open(); try { SqliteCommand selectCommand = new SqliteCommand( SqlCommandSelectPart + "FROM BusinessPartnerBanks " + "WHERE Identifier = @Identifier;", db); selectCommand.Parameters.AddWithValue("@Identifier", identifier); SqliteDataReader query = selectCommand.ExecuteReader(); if (query.Read()) { BusinessPartnerBankViewModel dbEntry = Read(query); businessPartnerBank = dbEntry; } } catch (SqliteException error) { MainWindow.ErrorMessage = error.Message; response.Success = false; response.Message = error.Message; response.BusinessPartnerBank = new BusinessPartnerBankViewModel(); return(response); } db.Close(); } response.Success = true; response.BusinessPartnerBank = businessPartnerBank; return(response); }