示例#1
0
        /// <summary>
        /// Loads the data for the view.
        /// </summary>
        public void LoadData( int id )
        {
            try
            {
                SetBusy( true );
                _memberContext.Load( _memberContext.GetMemberByIdQuery( id ), delegate( LoadOperation<Member> operation )
                {
                    if ( operation.HasError )
                    {
                        Status = "There was an error loading the member. " + operation.Error.Message;
                        operation.MarkErrorAsHandled();
                    }
                    else
                    {
                        var loadedMember = operation.Entities.FirstOrDefault();

                        if ( loadedMember != null )
                        {
                            SelectedMember = loadedMember;

                            LoadCountries();
                            LoadRoles();

                            if ( SelectedMember.Photo == null )
                            {
                                LoadDefaultPhoto();

                            }
                            else
                            {
                                LoadMemberPhoto( SelectedMember.Photo );
                                IsDefaultImage = false;
                            }
                            Mode = DataFormMode.Edit;
                        }
                        else if ( id == 0 )
                        {
                            LoadCountries();
                            LoadRoles();
                            LoadDefaultPhoto();

                            SelectedMember = new Member();
                            Mode = DataFormMode.AddNew;
                        }
                    }

                }, null );
            }
            catch ( InvalidOperationException ex )
            {
                MessageBox.Show( ex.Message );
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Members EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMembers(Member member)
 {
     base.AddObject("Members", member);
 }
        public void GetUserIdAndInsertMember( string name, Guid userId )
        {
            var m = new Member
                           {
                               Name = name,
                               Surname = string.Empty,
                               UserID = userId
                           };

            var teamService = new TeamService();
            teamService.InsertMember( m );
        }
 /// <summary>
 /// Create a new Member object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="userID">Initial value of the UserID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="surname">Initial value of the Surname property.</param>
 public static Member CreateMember(global::System.Int32 id, global::System.Guid userID, global::System.String name, global::System.String surname)
 {
     Member member = new Member();
     member.ID = id;
     member.UserID = userID;
     member.Name = name;
     member.Surname = surname;
     return member;
 }