public PopupMessage Insert(PopupMessage message)
 {
     try
     {
         connection.Open();
         var cmd = connection.CreateCommand() as SqlCommand;
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.CommandText = "PopUpMessage_Insert";
         cmd.Parameters.Add(new SqlParameter("@startDate", message.StartDate));
         cmd.Parameters.Add(new SqlParameter("@endDate", message.EndDate));
         cmd.Parameters.Add(new SqlParameter("@shortTitle", message.ShortTitle));
         cmd.Parameters.Add(new SqlParameter("@title", message.Title));
         cmd.Parameters.Add(new SqlParameter("@description", message.Description));
         if (message.ImageURL == null)
             message.ImageURL = "";
         cmd.Parameters.Add(new SqlParameter("@imageUrl", message.ImageURL));
         var idParameter = new SqlParameter("@ID", SqlDbType.Int) { Direction = ParameterDirection.Output };
         cmd.Parameters.Add(idParameter);
         cmd.ExecuteNonQuery();
         connection.Close();
         return message;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public HttpResponseMessage<PopupMessage> Post(PopupMessage message, HttpRequestMessage<PopupMessage> request)
        {
            if (message != null)
            {
                var messageDB = messageRepository.Insert(message);

                var response = new HttpResponseMessage<PopupMessage>(messageDB) { StatusCode = HttpStatusCode.Created };
                return response;
            }
            return new HttpResponseMessage<PopupMessage>(null) { StatusCode = HttpStatusCode.NotFound, };
        }
예제 #3
0
        public PopupMessageWindow(PopupMessage messageInfo)
        {
            InitializeComponent();

            popupRequests = new PopupMessageRequests(Constants.BaseApiUrl);

            this.Title = messageInfo.ShortTitle;
            this.TitleTextBox.Text = messageInfo.Title;
            this.Message.Text = string.Format(messageInfo.Description, Environment.NewLine);

            if (!string.IsNullOrEmpty(messageInfo.ImageURL))
            {
                this.ImageStackPanel.Visibility = Visibility.Visible;
                imageUrl = messageInfo.ImageURL;
                this.Image1.Source = new BitmapImage(new Uri(string.Format("{0}/messages/{1}", Configuration.ImagesPath, messageInfo.ImageURL), UriKind.Absolute));
            }
        }