public EmployeeAttachmentResponse Delete(Guid identifier) { EmployeeAttachmentResponse response = new EmployeeAttachmentResponse(); 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 EmployeeAttachments 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 EmployeeAttachmentResponse Delete(Guid identifier) { EmployeeAttachmentResponse response = new EmployeeAttachmentResponse(); try { response = WpfApiHandler.SendToApi <Guid, EmployeeAttachmentViewModel, EmployeeAttachmentResponse>(identifier, "Delete"); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } return(response); }
public EmployeeAttachmentResponse Create(EmployeeAttachmentViewModel EmployeeAttachment) { EmployeeAttachmentResponse response = new EmployeeAttachmentResponse(); try { response = WpfApiHandler.SendToApi <EmployeeAttachmentViewModel, EmployeeAttachmentResponse>(EmployeeAttachment, "Create"); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } return(response); }
public EmployeeAttachmentResponse Create(EmployeeAttachmentViewModel EmployeeAttachment) { EmployeeAttachmentResponse response = new EmployeeAttachmentResponse(); try { response.EmployeeAttachment = unitOfWork.GetEmployeeAttachmentRepository().Create(EmployeeAttachment.ConvertToEmployeeAttachment()) .ConvertToEmployeeAttachmentViewModel(); unitOfWork.Save(); response.Success = true; } catch (Exception ex) { response = new EmployeeAttachmentResponse(); response.Success = false; response.Message = ex.Message; } return(response); }
public EmployeeAttachmentResponse DeleteAll() { EmployeeAttachmentResponse response = new EmployeeAttachmentResponse(); 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 EmployeeAttachments "; 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 EmployeeAttachmentResponse Delete(Guid identifier) { EmployeeAttachmentResponse response = new EmployeeAttachmentResponse(); try { response.EmployeeAttachment = unitOfWork.GetEmployeeAttachmentRepository().Delete(identifier) .ConvertToEmployeeAttachmentViewModel(); unitOfWork.Save(); response.Success = true; } catch (Exception ex) { response = new EmployeeAttachmentResponse(); response.Success = false; response.Message = ex.Message; } return(response); }