//private bool mRolesLoaded; public MyProfileControl() { InitializeComponent(); Title = String.Format("Add New User"); mMyProfileViewModel = new MyProfileViewModel(new User { ActiveUser = true }); DataContext = mMyProfileViewModel; }
public MyProfileControl(MyProfileViewModel user) { InitializeComponent(); if (user.Id != 0) { mMyProfileViewModel = user; DataContext = mMyProfileViewModel; Title = String.Format("{0} {1}'s profile", mMyProfileViewModel.FirstName, mMyProfileViewModel.LastName); } else { //had to do it this way beacuse i could overload the constructor passing in an int because we already do below... Title = String.Format("Add New User To Role"); mMyProfileViewModel = new MyProfileViewModel(new User { ActiveUser = true, RoleId = user.Role.Id }); DataContext = mMyProfileViewModel; } }
private void GetUser(int userId) { CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); EventHandler<GetUserByIdCompletedEventArgs> fetchCompleted = null; fetchCompleted = (s1, eventArgs) => { User user = eventArgs.Result; mMyProfileViewModel = new MyProfileViewModel(user); Title = String.Format("{0} {1}'s profile", mMyProfileViewModel.FirstName, mMyProfileViewModel.LastName); DataContext = mMyProfileViewModel; }; cmsWebServiceClient.GetUserByIdCompleted += fetchCompleted; cmsWebServiceClient.GetUserByIdAsync(userId); }