public NewsDetailsViewModel(NewsChannel newsChannel, NewsItem newsItem)
        {
            if (newsChannel == null) throw new ArgumentNullException("newsChannel", "News channel cannot be null");
            if (newsItem == null) throw new ArgumentNullException("newsItem", "Source news item cannot be null");

            UpdateDetails(newsItem);
            ComposePublicationDetails(newsChannel, newsItem);
        }
Пример #2
0
        public bool SetNewsChannel(NewsChannel newschannel)
        {
            SqlConnection _connection = OneTapConnection.GetConnection;
            bool          status      = false;

            try
            {
                string result = "";


                _connection.Open();

                SqlCommand command = new SqlCommand("PROC_OneTap_Insert_NewsChannel");
                command.Connection = _connection;

                command.CommandType = System.Data.CommandType.StoredProcedure;
                var param = new SqlParameter();
                param.Direction     = ParameterDirection.Input;
                param.ParameterName = "@pnewschannel";
                param.Value         = newschannel.NewsChannelName;
                command.Parameters.Add(param);


                var outparam = new SqlParameter();
                outparam.Direction     = ParameterDirection.Output;
                outparam.ParameterName = "@retValue";
                outparam.SqlDbType     = SqlDbType.VarChar;
                outparam.Size          = 20;
                command.Parameters.Add(outparam);

                command.ExecuteNonQuery();

                result = (string)outparam.Value;
                status = result.ToLower().Equals("success");
            }

            catch (Exception)
            {
                if (_connection.State != ConnectionState.Closed)
                {
                    _connection.Close();
                }
                //throw;
                status = false;
            }
            finally
            {
                if (_connection.State != ConnectionState.Closed)
                {
                    _connection.Close();
                }
            }

            return(status);
        }
Пример #3
0
        public bool SetNewsChannel(string newschannel)
        {
            NewsChannel newchannel = new NewsChannel();

            newchannel.NewsChannelName = newschannel;

            using (NewsManager _newsManager = new NewsManager())
            {
                return(_newsManager.SetNewsChannel(newchannel));
            }
        }
Пример #4
0
    static void Main(string[] args)
    {
        // A Single news channgel
        NewsChannel n = new NewsChannel();

        // Setup all of the reporters
        NewsChannel_Watcher nick   = new NewsChannel_Watcher(n, "nick");
        NewsChannel_Watcher ashley = new NewsChannel_Watcher(n, "ashley");
        NewsChannel_Watcher emma   = new NewsChannel_Watcher(n, "emma");
        NewsChannel_Watcher megan  = new NewsChannel_Watcher(n, "megan");

        // Pulic a news item
        n.LatestNewsHeadline = "mark buys a drink";
    }
 private void ComposePublicationDetails(NewsChannel newsChannel, NewsItem newsItem)
 {
     PublicationDetails = newsItem.PublicationDate.ToString("dd.MM.yyy - HH:mm") + " • " + newsChannel.Name;
 }
Пример #6
0
 public NewsChannel_Watcher(NewsChannel nh, string name)
 {
     _name = name;
     nh.LatestNewsChange += new NewsChangeEventHandler(NewsChanged_Event);
 }