public bool AddSignature(Annotations customAnnotation) { using (IDbConnection db = new SqlConnection(ConfigurationValues.PostOfficeDatabaseConnection)) { try { string query = "INSERT INTO [Annotation]" + " (" + " [ActiveDirectoryUser]" + ",[Name]" + " ,[Annotation]" + " )" + " VALUES" + " (" + "@ActiveDirectoryUser,@Name,@Annotation" + " )"; db.Execute(query, new { @ActiveDirectoryUser = customAnnotation.ActiveDirectoryUser, @Name = customAnnotation.Name, @Annotation = customAnnotation.NewAnnotation }); return true; } catch (Exception er) { Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString()); return false; //Log.LogMessage(er.ToString()); } } }
public List<Annotations> GetAllSignatures() { List<Annotations> annotationsList = new List<Models.Annotations>(); List<Annotations> annotationsList2 = new List<Models.Annotations>(); Annotations annotations = new Annotations(); annotations.Id = 0; annotations.Name = "Select Signature"; annotationsList.Add(annotations); try { using (IDbConnection db = new SqlConnection(ConfigurationValues.PostOfficeDatabaseConnection)) { string query = "SELECT [ID],[ActiveDirectoryUser],[Name],[Annotation] as NewAnnotation" + " FROM [Annotation]" + " order by Name"; annotationsList2 = db.Query<Annotations>(query).ToList(); for (int i = 0; i < annotationsList2.Count; i++) { annotationsList.Add(annotationsList2[i]); } return annotationsList; } } catch (Exception er) { Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString()); return annotationsList; } }
public bool UpdateAnnotation(Annotations annotations) { using (IDbConnection db = new SqlConnection(ConfigurationValues.PostOfficeDatabaseConnection)) { try { string query = "update [Annotation]" + " set [ActiveDirectoryUser] = @ActiveDirectoryUser " + " , [Name] = @Name " //+ " , [Annotation] = @Annotation " + " where ID = @ID"; db.Execute(query, new { @ActiveDirectoryUser = annotations.ActiveDirectoryUser, @Name = annotations.Name, @ID = annotations.Id, }); return true; } catch (Exception er) { Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString()); return false; } } }