Ejemplo n.º 1
0
        public TestimonialViewModel GetViewModel()
        {
            TestimonialViewModel viewModel = new TestimonialViewModel();

            viewModel.Content           = Content;
            viewModel.ReceivedFrom      = ReceivedFrom;
            viewModel.ShortContent      = ShortContent;
            viewModel.TestimonialSerial = TestimonialSerial;
            return(viewModel);
        }
Ejemplo n.º 2
0
        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();
                }
            }
        }