public bool IsValidModel(PaperMetadata model) { return(IsNotEmpty(model.Title) && IsNotEmpty(model.Description) && IsNotEmpty(model.Year.ToString()) && IsNotEmpty(model.CategoryId.ToString())); }
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; } }
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; } }
public void Update(PaperMetadata paperMetadata) { _paperRepository.Update(paperMetadata); }
public void Create(PaperMetadata paperMetadata) { _paperRepository.Insert(paperMetadata); }