Example #1
0
 public Scope(ScopeData data)
 {
     Load(data);
 }
Example #2
0
        private void Load( ScopeData data )
        {
            Init();

            if ( data != null )
            {
                ScopeId = data.scope_id;
                Identifier = data.scope_identifier;
                Description = data.scope_description;
                CreatedByUserId = data.created_by;
                ModifiedByUserId = data.modified_by;
                DateCreated = data.date_created;
                DateModified = data.date_modified;
                Active = data.active;
            }
        }
Example #3
0
        public bool Save( string userId )
        {
            try
            {
                using ( OAuthDataContext context = OAuthContextHelper.GetContext() )
                {
                    ScopeData data;

                    if ( ScopeId > 0 )
                    {
                        data = context.ScopeDatas.FirstOrDefault( s => s.scope_id == ScopeId );

                        if ( data == null )
                        {
                            throw new ArgumentException( "Scope Id is not valid.", "ScopeId" );
                        }
                    }
                    else
                    {
                        if ( ScopeIdentifierInUse() )
                        {
                            throw new ArgumentException( "Scope Identifier is already in use.", "ScopeIdentifier" );
                        }

                        data = new ScopeData();
                        data.created_by = userId;
                        data.date_created = DateTime.Now;
                    }

                    data.scope_identifier = Identifier;
                    data.scope_description = Description;
                    data.modified_by = userId;
                    data.date_modified = DateTime.Now;
                    data.active = Active;

                    if(ScopeId <= 0)
                    {
                        context.ScopeDatas.InsertOnSubmit( data );
                    }

                    context.SubmitChanges();

                    if ( data.scope_id > 0 )
                    {
                        Load( data );
                        return true;
                    }

                    return false;
                }
            }
            catch ( Exception ex )
            {
                throw new Exception( "An error occurred while saving Scope", ex );
            }
        }
Example #4
0
 partial void DeleteScopeData(ScopeData instance);
Example #5
0
 partial void UpdateScopeData(ScopeData instance);
Example #6
0
 partial void InsertScopeData(ScopeData instance);