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

namespace MVVMProject
{
    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 MVVMProject.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;
    
    
    [DataContract(Namespace="http://schemas.datacontract.org/2004/07/MVVMProject.Web")]
    public sealed partial class Task : Entity
    {
        
        private Nullable<DateTime> _dueDate;
        
        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 OnDueDateChanging(Nullable<DateTime> value);
        partial void OnDueDateChanged();
        partial void OnIDChanging(long value);
        partial void OnIDChanged();
        partial void OnNameChanging(string value);
        partial void OnNameChanged();

        #endregion
        
        
        /// <summary>
        /// Default constructor.
        /// </summary>
        public Task()
        {
            this.OnCreated();
        }
        
        [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();
                }
            }
        }
        
        [DataMember()]
        [Key()]
        [RoundtripOriginal()]
        public long ID
        {
            get
            {
                return this._id;
            }
            set
            {
                if ((this._id != value))
                {
                    this.OnIDChanging(value);
                    this.RaiseDataMemberChanging("ID");
                    this.ValidateProperty("ID", value);
                    this._id = value;
                    this.RaiseDataMemberChanged("ID");
                    this.OnIDChanged();
                }
            }
        }
        
        [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();
                }
            }
        }
        
        public override object GetIdentity()
        {
            return this._id;
        }
    }
}
namespace MVVMProject.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 MVVMProject.Web;
    
    
    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>
        /// Default constructor.
        /// </summary>
        public DataContext() : 
                this(new WebDomainClient<IDataServiceContract>(new Uri("MVVMProject-Web-Services-DataService.svc", UriKind.Relative)))
        {
        }
        
        /// <summary>
        /// Constructor used to specify a data service URI.
        /// </summary>
        /// <param name="serviceUri">
        /// The DataService data service URI.
        /// </param>
        public DataContext(Uri serviceUri) : 
                this(new WebDomainClient<IDataServiceContract>(serviceUri))
        {
        }
        
        /// <summary>
        /// Constructor used to specify a DomainClient instance.
        /// </summary>
        /// <param name="domainClient">
        /// The DomainClient instance the DomainContext should use.
        /// </param>
        public DataContext(DomainClient domainClient) : 
                base(domainClient)
        {
            this.OnCreated();
        }
        
        public EntitySet<Task> Tasks
        {
            get
            {
                return base.EntityContainer.GetEntitySet<Task>();
            }
        }
        
        /// <summary>
        /// Returns an EntityQuery for query operation 'GetTasks'.
        /// </summary>
        public EntityQuery<Task> GetTasksQuery()
        {
            this.ValidateMethod("GetTasksQuery", null);
            return base.CreateQuery<Task>("GetTasks", null, false, true);
        }
        
        protected override EntityContainer CreateEntityContainer()
        {
            return new DataContextEntityContainer();
        }
        
        [ServiceContract()]
        public interface IDataServiceContract
        {
            
            [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);
            
            QueryResult<Task> EndGetTasks(IAsyncResult result);
            
            [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);
            
            IEnumerable<ChangeSetEntry> EndSubmitChanges(IAsyncResult result);
        }
        
        internal sealed class DataContextEntityContainer : EntityContainer
        {
            
            public DataContextEntityContainer()
            {
                this.CreateEntitySet<Task>(EntitySetOperations.All);
            }
        }
    }
}
