Esempio n. 1
0
 public bool IsValidModel(PaperMetadata model)
 {
     return(IsNotEmpty(model.Title) &&
            IsNotEmpty(model.Description) &&
            IsNotEmpty(model.Year.ToString()) &&
            IsNotEmpty(model.CategoryId.ToString()));
 }
Esempio n. 2
0
 public void Insert(PaperMetadata paperMetadata)
 {
     try
     {
         using (IDbConnection db = new SqlConnection(ConnectionString))
         {
             var query = @"INSERT INTO [dbo].[Paper] ([CategoryId],[Title],[Year],[Description])
                         VALUES (@CategoryId, @Title, @Year, @Description)";
             db.Execute(query, paperMetadata);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Esempio n. 3
0
 public void Update(PaperMetadata paperMetadata)
 {
     try
     {
         using (IDbConnection db = new SqlConnection(ConnectionString))
         {
             var query = @"UPDATE [dbo].[Paper]
                         SET [CategoryId] = @CategoryId, [Title] = @Title, 
                         [Year] = @Year, [Description] = @Description 
                         WHERE [Id] = @Id";
             db.Execute(query, paperMetadata);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Esempio n. 4
0
 public void Update(PaperMetadata paperMetadata)
 {
     _paperRepository.Update(paperMetadata);
 }
Esempio n. 5
0
 public void Create(PaperMetadata paperMetadata)
 {
     _paperRepository.Insert(paperMetadata);
 }