Esempio n. 1
0
        private void LoadUsersWithAgencyWithAgent()
        {
            UsersWithAgencyWithAgent = new ObservableCollection <UserAgencyAgentDTO>();
            var usrsWithAgencyWithAgent = _unitOfWork.UserRepository <UserAgencyAgentDTO>().Query()
                                          .Include(u => u.AgencyAgent, u => u.AgencyAgent.Agency, u => u.AgencyAgent.Agent)
                                          .Get().Where(u => u.UserId == SelectedUser.UserId).ToList();

            if (usrsWithAgencyWithAgent.Any())
            {
                UsersWithAgencyWithAgent =
                    new ObservableCollection <UserAgencyAgentDTO>(usrsWithAgencyWithAgent);
            }
        }
Esempio n. 2
0
        private void ExecuteSaveUserWithAgencyWithAgentViewCommand(object obj)
        {
            try
            {
                if (SelectedUserWithAgencyWithAgent != null)// && SelectedUserWithAgencyWithAgent.AgencyWithAgent != null)
                {
                    var agencyWithAg = new AgencyAgentDTO
                    {
                        AgencyId = SelectedLocalAgencyDto.Id,
                        AgentId  = SelectedForeignAgentDto.Id
                    };

                    //SelectedUserWithAgencyWithAgent.AgencyWithAgent.AgentId = SelectedForeignAgentDto.Id;
                    _unitOfWork.Repository <AgencyAgentDTO>()
                    .InsertUpdate(agencyWithAg);
                    //_unitOfWork.Commit();

                    SelectedUserWithAgencyWithAgent.AgencyWithAgentId = agencyWithAg.Id;
                    _unitOfWork.UserRepository <UserAgencyAgentDTO>()
                    .Insert(SelectedUserWithAgencyWithAgent);

                    _unitOfWork.Commit();

                    //_unitOfWork.Dispose();

                    CloseWindow(obj);
                }
            }
            catch (Exception ex)
            {
            }
        }