Пример #1
0
        public static void Channel_Update(Channel input)
        {
            SqlConnection connection = new SqlConnection(_ConnectionString);

            SqlCommand command = new SqlCommand("Channel_Update", connection);
            command.CommandType = CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@ChannelId", input.ChannelId);
            command.Parameters.AddWithValue("@ChannelName", input.ChannelName);

            SqlUtility.ExecuteNonQuery(command);
        }
Пример #2
0
 public ViewResult Edit(Channel channel)
 {
     if (ModelState.IsValid)
     {
         Provider.UpdateChannel(channel);
         return View("Index", Provider.GetChannels());
     }
     else
     {
         return View(channel);
     }
 }
Пример #3
0
 public ViewResult Create(Channel channel)
 {
     if (ModelState.IsValid)
     {
         Provider.CreateChannel(channel.ChannelName);
         return View("Index", Provider.GetChannels());
     }
     else
     {
         return View(channel);
     }
 }
Пример #4
0
        public void Channel_Tests()
        {
            Channel channel1 = new Channel();
            channel1.ChannelName = "Channel 3";
            Provider.CreateChannel(channel1.ChannelName);

            Channel channel2 = new Channel();
            channel2.ChannelName = "Channel C";
            Provider.CreateChannel(channel2.ChannelName);

            List<Channel> channels = Provider.GetChannels();
            channel1 = GetChannel(channel1.ChannelName, channels);
            Assert.IsTrue(channels.Contains(channel1));
            channel2 = GetChannel(channel2.ChannelName, channels);
            Assert.IsTrue(channels.Contains(channel2));
        }
Пример #5
0
 public static void UpdateChannel(Channel channel)
 {
     if (channel == null)
     {
         throw new Exception(string.Format(_InvalidMessage, "Channel"));
     }
     Data.Provider.Channel_Update(channel);
 }
Пример #6
0
        public static List<Channel> GetChannels()
        {
            List<Channel> returnValue = new List<Channel>();
            DataSet channelDataSet = Data.Provider.Channel_SelectAll();

            foreach (DataRow row in channelDataSet.Tables[0].Rows)
            {
                Channel channel = new Channel();
                channel.ChannelId = int.Parse(row["ChannelId"].ToString());
                channel.ChannelName = row["ChannelName"].ToString();
                returnValue.Add(channel);
            }
            return returnValue;
        }
Пример #7
0
        public static Channel GetChannel(int channelId)
        {
            Channel returnValue = new Channel();
            DataSet channelDataSet = Data.Provider.Channel_SelectById(channelId);

            returnValue.ChannelId = int.Parse(channelDataSet.Tables[0].Rows[0]["ChannelId"].ToString());
            returnValue.ChannelName = channelDataSet.Tables[0].Rows[0]["ChannelName"].ToString();

            return returnValue;
        }