//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.1
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Commands2
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.ServiceModel.DomainServices;
    using System.ServiceModel.DomainServices.Client;
    using System.ServiceModel.DomainServices.Client.ApplicationServices;
    
    
    /// <summary>
    /// Context for the RIA application.
    /// </summary>
    /// <remarks>
    /// This context extends the base to make application services and types available
    /// for consumption from code and xaml.
    /// </remarks>
    public sealed partial class WebContext : WebContextBase
    {
        
        #region Extensibility Method Definitions

        /// <summary>
        /// This method is invoked from the constructor once initialization is complete and
        /// can be used for further object setup.
        /// </summary>
        partial void OnCreated();

        #endregion
        
        
        /// <summary>
        /// Initializes a new instance of the WebContext class.
        /// </summary>
        public WebContext()
        {
            this.OnCreated();
        }
        
        /// <summary>
        /// Gets the context that is registered as a lifetime object with the current application.
        /// </summary>
        /// <exception cref="InvalidOperationException"> is thrown if there is no current application,
        /// no contexts have been added, or more than one context has been added.
        /// </exception>
        /// <seealso cref="System.Windows.Application.ApplicationLifetimeObjects"/>
        public new static WebContext Current
        {
            get
            {
                return ((WebContext)(WebContextBase.Current));
            }
        }
    }
}
namespace Commands2.Web
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.ServiceModel.DomainServices;
    using System.ServiceModel.DomainServices.Client;
    using System.ServiceModel.DomainServices.Client.ApplicationServices;
    
    
    /// <summary>
    /// The 'Task' entity class.
    /// </summary>
    [DataContract(Namespace="http://schemas.datacontract.org/2004/07/Commands2.Web")]
    public sealed partial class Task : Entity
    {
        
        private Nullable<DateTime> _completionDate;
        
        private DateTime _createdDate;
        
        private string _description;
        
        private Nullable<DateTime> _dueDate;
        
        private long _id;
        
        private DateTime _modifiedDate;
        
        private string _name;
        
        private long _taskCategoryID;
        
        #region Extensibility Method Definitions

        /// <summary>
        /// This method is invoked from the constructor once initialization is complete and
        /// can be used for further object setup.
        /// </summary>
        partial void OnCreated();
        partial void OnCompletionDateChanging(Nullable<DateTime> value);
        partial void OnCompletionDateChanged();
        partial void OnCreatedDateChanging(DateTime value);
        partial void OnCreatedDateChanged();
        partial void OnDescriptionChanging(string value);
        partial void OnDescriptionChanged();
        partial void OnDueDateChanging(Nullable<DateTime> value);
        partial void OnDueDateChanged();
        partial void OnIDChanging(long value);
        partial void OnIDChanged();
        partial void OnModifiedDateChanging(DateTime value);
        partial void OnModifiedDateChanged();
        partial void OnNameChanging(string value);
        partial void OnNameChanged();
        partial void OnTaskCategoryIDChanging(long value);
        partial void OnTaskCategoryIDChanged();

        #endregion
        
        
        /// <summary>
        /// Initializes a new instance of the <see cref="Task"/> class.
        /// </summary>
        public Task()
        {
            this.OnCreated();
        }
        
        /// <summary>
        /// Gets or sets the 'CompletionDate' value.
        /// </summary>
        [DataMember()]
        public Nullable<DateTime> CompletionDate
        {
            get
            {
                return this._completionDate;
            }
            set
            {
                if ((this._completionDate != value))
                {
                    this.OnCompletionDateChanging(value);
                    this.RaiseDataMemberChanging("CompletionDate");
                    this.ValidateProperty("CompletionDate", value);
                    this._completionDate = value;
                    this.RaiseDataMemberChanged("CompletionDate");
                    this.OnCompletionDateChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'CreatedDate' value.
        /// </summary>
        [DataMember()]
        public DateTime CreatedDate
        {
            get
            {
                return this._createdDate;
            }
            set
            {
                if ((this._createdDate != value))
                {
                    this.OnCreatedDateChanging(value);
                    this.RaiseDataMemberChanging("CreatedDate");
                    this.ValidateProperty("CreatedDate", value);
                    this._createdDate = value;
                    this.RaiseDataMemberChanged("CreatedDate");
                    this.OnCreatedDateChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'Description' value.
        /// </summary>
        [DataMember()]
        [StringLength(1000)]
        public string Description
        {
            get
            {
                return this._description;
            }
            set
            {
                if ((this._description != value))
                {
                    this.OnDescriptionChanging(value);
                    this.RaiseDataMemberChanging("Description");
                    this.ValidateProperty("Description", value);
                    this._description = value;
                    this.RaiseDataMemberChanged("Description");
                    this.OnDescriptionChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'DueDate' value.
        /// </summary>
        [DataMember()]
        public Nullable<DateTime> DueDate
        {
            get
            {
                return this._dueDate;
            }
            set
            {
                if ((this._dueDate != value))
                {
                    this.OnDueDateChanging(value);
                    this.RaiseDataMemberChanging("DueDate");
                    this.ValidateProperty("DueDate", value);
                    this._dueDate = value;
                    this.RaiseDataMemberChanged("DueDate");
                    this.OnDueDateChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'ID' value.
        /// </summary>
        [DataMember()]
        [Editable(false, AllowInitialValue=true)]
        [Key()]
        [RoundtripOriginal()]
        public long ID
        {
            get
            {
                return this._id;
            }
            set
            {
                if ((this._id != value))
                {
                    this.OnIDChanging(value);
                    this.ValidateProperty("ID", value);
                    this._id = value;
                    this.RaisePropertyChanged("ID");
                    this.OnIDChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'ModifiedDate' value.
        /// </summary>
        [DataMember()]
        public DateTime ModifiedDate
        {
            get
            {
                return this._modifiedDate;
            }
            set
            {
                if ((this._modifiedDate != value))
                {
                    this.OnModifiedDateChanging(value);
                    this.RaiseDataMemberChanging("ModifiedDate");
                    this.ValidateProperty("ModifiedDate", value);
                    this._modifiedDate = value;
                    this.RaiseDataMemberChanged("ModifiedDate");
                    this.OnModifiedDateChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'Name' value.
        /// </summary>
        [DataMember()]
        [Required()]
        [StringLength(250)]
        public string Name
        {
            get
            {
                return this._name;
            }
            set
            {
                if ((this._name != value))
                {
                    this.OnNameChanging(value);
                    this.RaiseDataMemberChanging("Name");
                    this.ValidateProperty("Name", value);
                    this._name = value;
                    this.RaiseDataMemberChanged("Name");
                    this.OnNameChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'TaskCategoryID' value.
        /// </summary>
        [DataMember()]
        public long TaskCategoryID
        {
            get
            {
                return this._taskCategoryID;
            }
            set
            {
                if ((this._taskCategoryID != value))
                {
                    this.OnTaskCategoryIDChanging(value);
                    this.RaiseDataMemberChanging("TaskCategoryID");
                    this.ValidateProperty("TaskCategoryID", value);
                    this._taskCategoryID = value;
                    this.RaiseDataMemberChanged("TaskCategoryID");
                    this.OnTaskCategoryIDChanged();
                }
            }
        }
        
        /// <summary>
        /// Computes a value from the key fields that uniquely identifies this entity instance.
        /// </summary>
        /// <returns>An object instance that uniquely identifies this entity instance.</returns>
        public override object GetIdentity()
        {
            return this._id;
        }
    }
    
    /// <summary>
    /// The 'TaskCategory' entity class.
    /// </summary>
    [DataContract(Namespace="http://schemas.datacontract.org/2004/07/Commands2.Web")]
    public sealed partial class TaskCategory : Entity
    {
        
        private long _id;
        
        private string _name;
        
        #region Extensibility Method Definitions

        /// <summary>
        /// This method is invoked from the constructor once initialization is complete and
        /// can be used for further object setup.
        /// </summary>
        partial void OnCreated();
        partial void OnIDChanging(long value);
        partial void OnIDChanged();
        partial void OnNameChanging(string value);
        partial void OnNameChanged();

        #endregion
        
        
        /// <summary>
        /// Initializes a new instance of the <see cref="TaskCategory"/> class.
        /// </summary>
        public TaskCategory()
        {
            this.OnCreated();
        }
        
        /// <summary>
        /// Gets or sets the 'ID' value.
        /// </summary>
        [DataMember()]
        [Editable(false, AllowInitialValue=true)]
        [Key()]
        [RoundtripOriginal()]
        public long ID
        {
            get
            {
                return this._id;
            }
            set
            {
                if ((this._id != value))
                {
                    this.OnIDChanging(value);
                    this.ValidateProperty("ID", value);
                    this._id = value;
                    this.RaisePropertyChanged("ID");
                    this.OnIDChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'Name' value.
        /// </summary>
        [DataMember()]
        [Required()]
        [StringLength(50)]
        public string Name
        {
            get
            {
                return this._name;
            }
            set
            {
                if ((this._name != value))
                {
                    this.OnNameChanging(value);
                    this.RaiseDataMemberChanging("Name");
                    this.ValidateProperty("Name", value);
                    this._name = value;
                    this.RaiseDataMemberChanged("Name");
                    this.OnNameChanged();
                }
            }
        }
        
        /// <summary>
        /// Computes a value from the key fields that uniquely identifies this entity instance.
        /// </summary>
        /// <returns>An object instance that uniquely identifies this entity instance.</returns>
        public override object GetIdentity()
        {
            return this._id;
        }
    }
}
namespace Commands2.Web.Services
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.ServiceModel;
    using System.ServiceModel.DomainServices;
    using System.ServiceModel.DomainServices.Client;
    using System.ServiceModel.DomainServices.Client.ApplicationServices;
    using System.ServiceModel.Web;
    using Commands2.Web;
    
    
    /// <summary>
    /// The domain context corresponding to the 'DataService' domain service.
    /// </summary>
    public sealed partial class DataContext : DomainContext
    {
        
        #region Extensibility Method Definitions

        /// <summary>
        /// This method is invoked from the constructor once initialization is complete and
        /// can be used for further object setup.
        /// </summary>
        partial void OnCreated();

        #endregion
        
        
        /// <summary>
        /// Initializes a new instance of the <see cref="DataContext"/> class.
        /// </summary>
        public DataContext() : 
                this(new WebDomainClient<IDataServiceContract>(new Uri("Commands2-Web-Services-DataService.svc", UriKind.Relative)))
        {
        }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="DataContext"/> class with the specified service URI.
        /// </summary>
        /// <param name="serviceUri">The DataService service URI.</param>
        public DataContext(Uri serviceUri) : 
                this(new WebDomainClient<IDataServiceContract>(serviceUri))
        {
        }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="DataContext"/> class with the specified <paramref name="domainClient"/>.
        /// </summary>
        /// <param name="domainClient">The DomainClient instance to use for this domain context.</param>
        public DataContext(DomainClient domainClient) : 
                base(domainClient)
        {
            this.OnCreated();
        }
        
        /// <summary>
        /// Gets the set of <see cref="TaskCategory"/> entities that have been loaded into this <see cref="DataContext"/> instance.
        /// </summary>
        public EntitySet<TaskCategory> TaskCategories
        {
            get
            {
                return base.EntityContainer.GetEntitySet<TaskCategory>();
            }
        }
        
        /// <summary>
        /// Gets the set of <see cref="Task"/> entities that have been loaded into this <see cref="DataContext"/> instance.
        /// </summary>
        public EntitySet<Task> Tasks
        {
            get
            {
                return base.EntityContainer.GetEntitySet<Task>();
            }
        }
        
        /// <summary>
        /// Gets an EntityQuery instance that can be used to load <see cref="TaskCategory"/> entities using the 'GetTaskCategories' query.
        /// </summary>
        /// <returns>An EntityQuery that can be loaded to retrieve <see cref="TaskCategory"/> entities.</returns>
        public EntityQuery<TaskCategory> GetTaskCategoriesQuery()
        {
            this.ValidateMethod("GetTaskCategoriesQuery", null);
            return base.CreateQuery<TaskCategory>("GetTaskCategories", null, false, true);
        }
        
        /// <summary>
        /// Gets an EntityQuery instance that can be used to load <see cref="Task"/> entities using the 'GetTasks' query.
        /// </summary>
        /// <returns>An EntityQuery that can be loaded to retrieve <see cref="Task"/> entities.</returns>
        public EntityQuery<Task> GetTasksQuery()
        {
            this.ValidateMethod("GetTasksQuery", null);
            return base.CreateQuery<Task>("GetTasks", null, false, true);
        }
        
        /// <summary>
        /// Gets an EntityQuery instance that can be used to load <see cref="Task"/> entities using the 'GetTasksByCategory' query.
        /// </summary>
        /// <param name="id">The value for the 'id' parameter of the query.</param>
        /// <returns>An EntityQuery that can be loaded to retrieve <see cref="Task"/> entities.</returns>
        public EntityQuery<Task> GetTasksByCategoryQuery(long id)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("id", id);
            this.ValidateMethod("GetTasksByCategoryQuery", parameters);
            return base.CreateQuery<Task>("GetTasksByCategory", parameters, false, true);
        }
        
        /// <summary>
        /// Creates a new entity container for this domain context's entity sets.
        /// </summary>
        /// <returns>A new container instance.</returns>
        protected override EntityContainer CreateEntityContainer()
        {
            return new DataContextEntityContainer();
        }
        
        /// <summary>
        /// Service contract for the 'DataService' domain service.
        /// </summary>
        [ServiceContract()]
        public interface IDataServiceContract
        {
            
            /// <summary>
            /// Asynchronously invokes the 'GetTaskCategories' operation.
            /// </summary>
            /// <param name="callback">Callback to invoke on completion.</param>
            /// <param name="asyncState">Optional state object.</param>
            /// <returns>An IAsyncResult that can be used to monitor the request.</returns>
            [FaultContract(typeof(DomainServiceFault), Action="http://tempuri.org/DataService/GetTaskCategoriesDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/DataService/GetTaskCategories", ReplyAction="http://tempuri.org/DataService/GetTaskCategoriesResponse")]
            [WebGet()]
            IAsyncResult BeginGetTaskCategories(AsyncCallback callback, object asyncState);
            
            /// <summary>
            /// Completes the asynchronous operation begun by 'BeginGetTaskCategories'.
            /// </summary>
            /// <param name="result">The IAsyncResult returned from 'BeginGetTaskCategories'.</param>
            /// <returns>The 'QueryResult' returned from the 'GetTaskCategories' operation.</returns>
            QueryResult<TaskCategory> EndGetTaskCategories(IAsyncResult result);
            
            /// <summary>
            /// Asynchronously invokes the 'GetTasks' operation.
            /// </summary>
            /// <param name="callback">Callback to invoke on completion.</param>
            /// <param name="asyncState">Optional state object.</param>
            /// <returns>An IAsyncResult that can be used to monitor the request.</returns>
            [FaultContract(typeof(DomainServiceFault), Action="http://tempuri.org/DataService/GetTasksDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/DataService/GetTasks", ReplyAction="http://tempuri.org/DataService/GetTasksResponse")]
            [WebGet()]
            IAsyncResult BeginGetTasks(AsyncCallback callback, object asyncState);
            
            /// <summary>
            /// Completes the asynchronous operation begun by 'BeginGetTasks'.
            /// </summary>
            /// <param name="result">The IAsyncResult returned from 'BeginGetTasks'.</param>
            /// <returns>The 'QueryResult' returned from the 'GetTasks' operation.</returns>
            QueryResult<Task> EndGetTasks(IAsyncResult result);
            
            /// <summary>
            /// Asynchronously invokes the 'GetTasksByCategory' operation.
            /// </summary>
            /// <param name="id">The value for the 'id' parameter of this action.</param>
            /// <param name="callback">Callback to invoke on completion.</param>
            /// <param name="asyncState">Optional state object.</param>
            /// <returns>An IAsyncResult that can be used to monitor the request.</returns>
            [FaultContract(typeof(DomainServiceFault), Action="http://tempuri.org/DataService/GetTasksByCategoryDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/DataService/GetTasksByCategory", ReplyAction="http://tempuri.org/DataService/GetTasksByCategoryResponse")]
            [WebGet()]
            IAsyncResult BeginGetTasksByCategory(long id, AsyncCallback callback, object asyncState);
            
            /// <summary>
            /// Completes the asynchronous operation begun by 'BeginGetTasksByCategory'.
            /// </summary>
            /// <param name="result">The IAsyncResult returned from 'BeginGetTasksByCategory'.</param>
            /// <returns>The 'QueryResult' returned from the 'GetTasksByCategory' operation.</returns>
            QueryResult<Task> EndGetTasksByCategory(IAsyncResult result);
            
            /// <summary>
            /// Asynchronously invokes the 'SubmitChanges' operation.
            /// </summary>
            /// <param name="changeSet">The change-set to submit.</param>
            /// <param name="callback">Callback to invoke on completion.</param>
            /// <param name="asyncState">Optional state object.</param>
            /// <returns>An IAsyncResult that can be used to monitor the request.</returns>
            [FaultContract(typeof(DomainServiceFault), Action="http://tempuri.org/DataService/SubmitChangesDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/DataService/SubmitChanges", ReplyAction="http://tempuri.org/DataService/SubmitChangesResponse")]
            IAsyncResult BeginSubmitChanges(IEnumerable<ChangeSetEntry> changeSet, AsyncCallback callback, object asyncState);
            
            /// <summary>
            /// Completes the asynchronous operation begun by 'BeginSubmitChanges'.
            /// </summary>
            /// <param name="result">The IAsyncResult returned from 'BeginSubmitChanges'.</param>
            /// <returns>The collection of change-set entry elements returned from 'SubmitChanges'.</returns>
            IEnumerable<ChangeSetEntry> EndSubmitChanges(IAsyncResult result);
        }
        
        internal sealed class DataContextEntityContainer : EntityContainer
        {
            
            public DataContextEntityContainer()
            {
                this.CreateEntitySet<Task>(EntitySetOperations.All);
                this.CreateEntitySet<TaskCategory>(EntitySetOperations.None);
            }
        }
    }
}
