#region License

// Copyright (c) 2013, ClearCanvas Inc.
// All rights reserved.
// http://www.ClearCanvas.ca
//
// This file is part of the ClearCanvas RIS/PACS open source project.
//
// The ClearCanvas RIS/PACS open source project is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// The ClearCanvas RIS/PACS open source project is distributed in the hope that it
// will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
// Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// the ClearCanvas RIS/PACS open source project.  If not, see
// <http://www.gnu.org/licenses/>.

#endregion

// This file is auto-generated by the Macro.Model.SqlServer.CodeGenerator project.

namespace Macro.ImageServer.Model
{
    using System;
    using System.Xml;
    using Macro.Dicom;
    using Macro.Enterprise.Core;
    using Macro.ImageServer.Enterprise;
    using Macro.ImageServer.Model.EntityBrokers;

    [Serializable]
    public partial class RequestAttributes: ServerEntity
    {
        #region Constructors
        public RequestAttributes():base("RequestAttributes")
        {}
        public RequestAttributes(
             ServerEntityKey _seriesKey_
            ,String _requestedProcedureId_
            ,String _scheduledProcedureStepId_
            ):base("RequestAttributes")
        {
            SeriesKey = _seriesKey_;
            RequestedProcedureId = _requestedProcedureId_;
            ScheduledProcedureStepId = _scheduledProcedureStepId_;
        }
        #endregion

        #region Public Properties
        [EntityFieldDatabaseMappingAttribute(TableName="RequestAttributes", ColumnName="SeriesGUID")]
        public ServerEntityKey SeriesKey
        { get; set; }
        [DicomField(DicomTags.RequestedProcedureId, DefaultValue = DicomFieldDefault.Null)]
        [EntityFieldDatabaseMappingAttribute(TableName="RequestAttributes", ColumnName="RequestedProcedureId")]
        public String RequestedProcedureId
        { get; set; }
        [DicomField(DicomTags.ScheduledProcedureStepId, DefaultValue = DicomFieldDefault.Null)]
        [EntityFieldDatabaseMappingAttribute(TableName="RequestAttributes", ColumnName="ScheduledProcedureStepId")]
        public String ScheduledProcedureStepId
        { get; set; }
        #endregion

        #region Static Methods
        static public RequestAttributes Load(ServerEntityKey key)
        {
            using (var read = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
            {
                return Load(read, key);
            }
        }
        static public RequestAttributes Load(IPersistenceContext read, ServerEntityKey key)
        {
            var broker = read.GetBroker<IRequestAttributesEntityBroker>();
            RequestAttributes theObject = broker.Load(key);
            return theObject;
        }
        static public RequestAttributes Insert(RequestAttributes entity)
        {
            using (var update = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
            {
                RequestAttributes newEntity = Insert(update, entity);
                update.Commit();
                return newEntity;
            }
        }
        static public RequestAttributes Insert(IUpdateContext update, RequestAttributes entity)
        {
            var broker = update.GetBroker<IRequestAttributesEntityBroker>();
            var updateColumns = new RequestAttributesUpdateColumns();
            updateColumns.SeriesKey = entity.SeriesKey;
            updateColumns.RequestedProcedureId = entity.RequestedProcedureId;
            updateColumns.ScheduledProcedureStepId = entity.ScheduledProcedureStepId;
            RequestAttributes newEntity = broker.Insert(updateColumns);
            return newEntity;
        }
        #endregion
    }
}
