public void Post([FromBody] delCustNews cusNews) { if (cusNews != null) { CustomerNews sub = new CustomerNews { Title = cusNews.Title, Description = cusNews.Description, Date = cusNews.Date }; customerMediator.InsertNews(sub, cusNews.cusId); } }
/// <summary> /// Inserts a news for a specified customer /// </summary> /// <param name="cusNews">The news to be inserted</param> /// <param name="cusId">The unique customer ID</param> /// <returns>A news</returns> public async Task <CustomerNews> InsertNews(CustomerNews cusNews, int cusId) { using (var connection = new SqlConnection(this.connectionString)) { var cmd = new SqlCommand("INSERT INTO [dbo].[CustomerNews] (Title, NewsDescription, NewsDate, customerId) " + "VALUES (@title, @newsDescription, @newsDate, @customerId)", connection); cmd.Parameters.AddWithValue("@title", SqlDbType.VarChar).Value = cusNews.Title; cmd.Parameters.AddWithValue("@newsDescription", SqlDbType.VarChar).Value = cusNews.Description; cmd.Parameters.AddWithValue("@newsDate", SqlDbType.Date).Value = cusNews.Date; cmd.Parameters.AddWithValue("@customerId", SqlDbType.Int).Value = cusId; await connection.OpenAsync(); int result = await cmd.ExecuteNonQueryAsync(); } return(cusNews); }
public async Task <CustomerNews> InsertNews(CustomerNews cusNews, int cusId) { return(await customerDataAccess.InsertNews(cusNews, cusId)); }
public async Task <CustomerNews> InsertNews(CustomerNews cusNews, int cusId) { return(await customerRepository.InsertNews(cusNews, cusId)); }