public TestimonialViewModel GetViewModel() { TestimonialViewModel viewModel = new TestimonialViewModel(); viewModel.Content = Content; viewModel.ReceivedFrom = ReceivedFrom; viewModel.ShortContent = ShortContent; viewModel.TestimonialSerial = TestimonialSerial; return(viewModel); }
public void Add(TestimonialViewModel testimonialViewModel) { using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand("INSERT INTO [cms_Testimonial] ( [Content], [ShortContent], [ReceivedFrom] ) VALUES (@Content, @ShortContent, @ReceivedFrom)", cn)) { cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@Content", SqlDbType.NVarChar).Value = testimonialViewModel.Content; cmd.Parameters.Add("@ShortContent", SqlDbType.NVarChar).Value = testimonialViewModel.ShortContent; cmd.Parameters.Add("@ReceivedFrom", SqlDbType.NVarChar).Value = testimonialViewModel.ReceivedFrom; cmd.Connection.Open(); cmd.ExecuteNonQuery(); cmd.Connection.Close(); } } }