// ----------------------------------------------------------------------------------
// Microsoft Developer & Platform Evangelism
// 
// Copyright (c) Microsoft Corporation. All rights reserved.
// 
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// ----------------------------------------------------------------------------------
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
// ----------------------------------------------------------------------------------

namespace Microsoft.Samples.WindowsAzureMmc.Model.Storage
{
    using System;
    using System.ComponentModel;
    using System.Management.Automation;

    public class AzureMessage : AzureObject
    {
        public AzureMessage(PSObject powershellObject)
        {
            this.PSObject = powershellObject;

            if (powershellObject.Properties["ExpirationTime"].Value != null)
            {
                this.ExpirationTime = (DateTime)powershellObject.Properties["ExpirationTime"].Value;
            }

            this.Id = powershellObject.Properties["Id"].Value.ToString();
            this.Name = this.Id;
            this.InsertionTime = (DateTime)powershellObject.Properties["InsertionTime"].Value;
            
            if (powershellObject.Properties["PopReceipt"].Value != null)
            {
                this.PopReceipt = powershellObject.Properties["PopReceipt"].Value.ToString();
            }

            if (powershellObject.Properties["NextVisibleTime"].Value != null)
            {
                this.TimeNextVisible = (DateTime)powershellObject.Properties["TimeNextVisible"].Value;
            }
        }

        [ReadOnly(true)]
        public string ContentAsString { get; set; }

        [ReadOnly(true)]
        public DateTime ExpirationTime { get; set; }

        [ReadOnly(true)]
        public string Id { get; set; }

        [ReadOnly(true)]
        public DateTime InsertionTime { get; set; }

        [ReadOnly(true)]
        public string PopReceipt { get; set; }

        [ReadOnly(true)]
        public DateTime TimeNextVisible { get; set; }
    }
}