public UserRateListViewModel(IUserInterop userInterop, IControllerInterop controllerInterop, Dispatcher dispatcher, BaseEntityDTO entity) : base(userInterop, controllerInterop, dispatcher) { this.entity = entity; rates = new ObservableCollection<UserRateItemDTO>(); Rates = new ReadOnlyObservableCollection<UserRateItemDTO>(rates); }
public async Task <IActionResult> GetPerfis() { IActionResult res = null; var b = new BaseEntityDTO <IEnumerable <GrupoUsuariosModel> >() { Start = DateTime.Now }; try { var dados = await new GrupoUsuariosRepository().ListaGrupos(ClienteID); if (dados == null || !dados.Any()) { return(NoContent()); } b.Result = dados; b.End = DateTime.Now; b.Itens = dados.Count(); res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public async Task <IActionResult> RelatorioInvalidosAsync([FromBody] ConsolidadoModel c) { IActionResult res = null; var b = new BaseEntityDTO <IEnumerable <ConsolidadoInvalidosModel> >() { Start = DateTime.Now }; try { var dados = await new ConsolidadoRepository().RelatorioInvalidosAsync(c, ClienteID, UsuarioID); if (!dados.Any()) { return(NoContent()); } //throw new Exception($"Sem dados para consulta do dia {c.DataInicial.ToString("dd/MM/yyyy")} ao dia {c.DataFinal.ToString("dd/MM/yyyy")}"); b.Result = dados; b.Itens = dados.Count(); b.End = DateTime.Now; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public async Task <IActionResult> AlteraSaldo([FromBody] IEnumerable <UsuarioModel> t) { IActionResult res = null; var b = new BaseEntityDTO <string>() { Start = DateTime.Now }; try { var dados = await new UsuarioRepository().RenovaSaldoUsuario(t.ElementAt(0), ClienteID); if (dados < 0) { throw new Exception("Houve um erro na atualização de saldo do usuário"); } b.Result = $"Usuário atualizado com sucesso"; b.Itens = t.Count(); b.End = DateTime.Now; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public async Task <IActionResult> Leiautes() { IActionResult res = null; var b = new BaseEntityDTO <IEnumerable <LeiauteModel> >() { Start = DateTime.Now }; try { b.Result = await new LeiauteRepository().ListaLayouts(ClienteID, UsuarioID); if (!b.Result.Any()) { return(NoContent()); } b.Itens = b.Result.Count(); b.End = DateTime.Now; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public async Task <IActionResult> GenericCall <T>(int ClienteID, int?UsuarioID, IRepository <T> repo, T t) where T : class { IActionResult res = null; var b = new BaseEntityDTO <IEnumerable <T> > { Start = DateTime.Now }; try { b.Result = await repo.GetAll(t, UsuarioID); if (b.Result == null || !b.Result.Any()) { return(NoContent()); } b.Itens = b.Result.Count(); b.End = DateTime.Now; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public async Task <IActionResult> AdicionaItemAsync([FromBody] IEnumerable <TipoCampanhaModel> t) { IActionResult res = null; var b = new BaseEntityDTO <TipoCampanhaModel>() { Start = DateTime.Now, Itens = t.Count() }; try { await repository.Add(t, ClienteID, UsuarioID); b.End = DateTime.Now; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; if (b.Error.Contains("IX_TIPOCAMPANHA")) { b.Error = $"Tipo de Campanha: {t.ElementAt(0).TipoCampanha} já existente"; } res = BadRequest(b); } return(res); }
public async Task <IActionResult> Previsto() { IActionResult res = null; var b = new BaseEntityDTO <dynamic>() { Start = DateTime.Now }; try { var result = await new FornecedorRepository().Previsto(FornecedorID); if (result == null) { return(NoContent()); } b.Result = result; b.End = DateTime.Now; b.Itens = 1; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
protected async Task <bool> EditItem <T>(BaseEntityDTO dto, Action <T> action = null, bool mapToOne = true) where T : BaseEntity { var ent = mapper.Map <T>(dto); var item = await ctx.Set <T>().FindAsync(ent.Id); if (item == null) { return(false); } if (mapToOne) { mapper.Map(dto, item); } else { item = mapper.Map <T>(dto); } if (action != null) { action.Invoke(item); } return(await ctx.SaveChangesAsync() > 0); }
public async Task <IActionResult> GetAllExistentes() { IActionResult res = null; var b = new BaseEntityDTO <bool>() { Start = DateTime.Now }; try { var dados = await new FornecedorRepository().FornecedoresCliente(ClienteID); b.Result = dados > 0; b.End = DateTime.Now; b.Itens = dados; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public async Task <IActionResult> GetAll() { IActionResult res = null; var b = new BaseEntityDTO <IEnumerable <PadraoPostagensModel> >() { Start = DateTime.Now }; try { b.Result = (await repository.GetAll(new PadraoPostagensModel() { Cliente = new ClienteModel() { ClienteID = ClienteID } }, UsuarioID)); b.End = DateTime.Now; b.Itens = b.Result.Count(); res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public async Task <IActionResult> AtualizaItemAsync([FromBody] IEnumerable <PadraoPostagensModel> t) { IActionResult res = null; var b = new BaseEntityDTO <PadraoPostagensModel>() { Start = DateTime.Now, Itens = t.Count() }; try { await repository.Update(t, ClienteID, UsuarioID); b.End = DateTime.Now; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; if (b.Error.Contains("IX_PADRAO_POSTAGENS")) { b.Error = "Padrão já cadastrado"; } res = BadRequest(b); } return(res); }
public async Task <IActionResult> AdiicionaItem([FromBody] IEnumerable <PadraoPostagensModel> t) { IActionResult res = null; var b = new BaseEntityDTO <PadraoPostagensModel>() { Start = DateTime.Now, Itens = t.Count() }; try { Regex regPadraoArquivo = new Regex("([0-9]{8}|[0-9]{6}).(txt|csv|TXT|CSV)", RegexOptions.Compiled); var padrao = t.ElementAt(0); padrao.Padrao = regPadraoArquivo.Replace(padrao.Padrao, string.Empty); b.Result = await new PadraoPostagensRepository().Adicionaitem(padrao, ClienteID, UsuarioID); b.End = DateTime.Now; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public async Task <IActionResult> GetAllPaginadoAsync([FromBody] PadraoPostagensModel t) { IActionResult res = null; var b = new BaseEntityDTO <IEnumerable <PadraoPostagensModel> >() { Start = DateTime.Now }; try { t.Cliente = new ClienteModel() { ClienteID = ClienteID }; b.Result = await repository.GetAllPaginado(t, UsuarioID); if (!b.Result.Any() || b.Result == null) { return(NoContent()); } b.End = DateTime.Now; b.Itens = b.Result.Count(); res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public async Task <IActionResult> GetByIDAsync(int id) { IActionResult res = null; var b = new BaseEntityDTO <LeiauteModel>() { Start = DateTime.Now }; try { b.Result = await repository.FindById(new LeiauteModel() { LeiauteID = id, Cliente = new ClienteModel() { ClienteID = ClienteID } }, UsuarioID); if (b.Result != null) { b.Itens = 1; } b.End = DateTime.Now; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public async Task <IActionResult> DashBoard() { IActionResult res = null; var b = new BaseEntityDTO <dynamic>() { Start = DateTime.Now }; try { var dados = await new RetornoRepository().DashBoard(ClienteID); if (dados == null || !dados.Any()) { return(NoContent()); } b.Result = new { classificacoes = dados.Select(a => new { Classificacao = a.ClassificacaoIOPeople, Quantidade = a.Quantidade }), registros = dados.Sum(k => k.Quantidade) }; b.End = DateTime.Now; b.Itens = dados.Count(); res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public async Task <IActionResult> GetAll() { IActionResult res = null; var b = new BaseEntityDTO <IEnumerable <RetornoModel> >() { Start = DateTime.Now }; try { b.Result = await repository.GetAll(new RetornoModel() { ClienteID = ClienteID }, UsuarioID); if (b.Result != null || !b.Result.Any()) { return(NoContent()); } b.End = DateTime.Now; b.Itens = b.Result.Count(); res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public async Task <IActionResult> Redistribuicao() { IActionResult res = null; var b = new BaseEntityDTO <IEnumerable <FornecedorModel> >() { Start = DateTime.Now }; try { b.Result = await new FornecedorRepository().Redistribuicao(ClienteID); if (b.Result == null || !b.Result.Any()) { return(NoContent()); } b.End = DateTime.Now; b.Itens = b.Result.Count(); res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public async Task <IActionResult> Logout([FromBody] LoginViewModel l) { IActionResult res = null; var _b = new BaseEntityDTO <dynamic>() { Start = DateTime.Now, Itens = 1 }; try { if (User.FindFirst(a => a.Type == "fornecedorid") == null) { var x = HttpContext.Request.Headers["Guid"]; await new SessionDataRepository().Remove(new SessionDataModel[] { new SessionDataModel { Guid = x } }, ClienteID, null); } _b.End = DateTime.Now; _b.Itens = 1; res = Ok(_b); } catch (Exception err) { _b.End = DateTime.Now; _b.Error = (err.InnerException ?? err).Message; res = BadRequest(_b); } return(res); }
public async Task <IActionResult> AtualizaItemAsync([FromBody] IEnumerable <SegmentacaoModel> t) { IActionResult res = null; var b = new BaseEntityDTO <SegmentacaoModel>() { Start = DateTime.Now, Itens = t.Count() }; try { await repository.Update(t, ClienteID, UsuarioID); b.End = DateTime.Now; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; if (b.Error.Contains("IX_SEGMENTACAO")) { b.Error = $"Item já existente: {t.ElementAt(0).Nome}"; } res = BadRequest(b); } return(res); }
public async Task <IActionResult> AtualizaItemAsync([FromBody] IEnumerable <BlackListModel> t) { IActionResult res = null; var b = new BaseEntityDTO <BlackListModel>() { Start = DateTime.Now, Itens = t.Count() }; try { await repository.Update(t, ClienteID, UsuarioID); b.End = DateTime.Now; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; if (b.Error.Contains("IX_CELULAR_BLACKLIST")) { b.Error = $"Número já existente na blacklist: {t.ElementAt(0).Celular}"; } res = BadRequest(b); } return(res); }
public async Task <IActionResult> Search(string s) { IActionResult res = null; var b = new BaseEntityDTO <IEnumerable <SegmentacaoModel> >() { Start = DateTime.Now }; try { b.Result = await repository.Search(new SegmentacaoModel() { Cliente = new ClienteModel() { ClienteID = ClienteID } }, s, UsuarioID); b.Itens = b.Result.Count(); b.End = DateTime.Now; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public async Task <IActionResult> RedistribuiLotesFornecedores([FromBody] IEnumerable <FornecedorMinModel> f, int arquivoid, int carteiraid) { IActionResult res = null; var b = new BaseEntityDTO <int>() { Start = DateTime.Now }; try { if (f.Sum(a => a.Distribuicao) != 100) { throw new Exception("A soma da distribuição não corresponde a 100%"); } b.Result = await new FornecedorRepository().RedistribuiLotes(f, arquivoid, carteiraid, ClienteID, UsuarioID); b.End = DateTime.Now; b.Itens = b.Result; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public async Task <IActionResult> AdicionaItemAsync([FromBody] IEnumerable <LeiauteModel> t) { IActionResult res = null; var b = new BaseEntityDTO <LeiauteModel>() { Start = DateTime.Now, Itens = t.Count() }; try { int contador = 0; foreach (var item in t) { foreach (var _i in item.LeiauteVariaveis) { _i.Variavel = string.IsNullOrEmpty(_i.Variavel) ? $"#ignorar{contador++}" : _i.Variavel; if (!regVariavel.IsMatch(_i.Variavel)) { throw new Exception($"Variável {_i.Variavel} inválida"); } } if (!item.LeiauteVariaveis.Any(a => a.Variavel == "#numero")) { throw new Exception("Variável #numero não constante na listagem"); } } await repository.Add(t, ClienteID, UsuarioID); b.End = DateTime.Now; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; if (b.Error.Contains("IX_LAYOUT_UNIQUE_CLIENTEID_NOM")) { b.Error = $"Padrão com o nome {t.ElementAt(0).Nome} já existente no sistema"; } if (b.Error.Contains("IX_VARIAVEL_LAYOUT")) { b.Error = $"Item de variável já existente"; } else if (b.Error.Contains("IX_IDCOLUNA_LAYOUT")) { b.Error = "ID de coluna duplicado"; } res = BadRequest(b); } return(res); }
public override void Assign(BaseEntityDTO entity) { base.Assign(entity); FacultyDTO faculty = entity as FacultyDTO; this.Institute = faculty.Institute; this.specializations = faculty.Specializations.ToModelList<SpecializationModel, SpecializationDTO>(); }
public override void Assign(BaseEntityDTO entity) { base.Assign(entity); NotificationDTO notification = entity as NotificationDTO; this.message = notification.Message; this.date = notification.Date; }
protected T AddItem <T>(BaseEntityDTO dto) where T : BaseEntity { var item = mapper.Map <T>(dto); ctx.Set <T>().Add(item); return(item); }
public async Task <IActionResult> Especializado([FromBody] ConsolidadoModel c, int?carteiraid) { //Scheduler.NewThread.Schedule(.Schedule(() => UrlShoortnerGoogle(campanhas)); IActionResult res = null; var b = new BaseEntityDTO <dynamic>() { Start = DateTime.Now }; try { var dados = await new ConsolidadoRepository().Especializado(c, ClienteID, UsuarioID); if (dados == null || !dados.Any()) { return(NoContent()); } b.Result = new { paginas = dados.ElementAt(0).Paginas, registros = dados.ElementAt(0).Registros, dados = dados.Select(a => new { arquivo = a.Arquivo, carteira = a.Carteira, spgrande = a.SpGrande, spcapital = a.SpCapital, demaisddd = a.DemaisDDD, validade = a.Validade, enviados = a.Enviados, invalidos = a.CelularInvalido, excluidas = a.Excluidas, codigo = a.Codigo, celularinvalido = a.CelularInvalido, nomeusuario = a.UsuarioNome, fornecedor = a.FornecedorNome, datadia = a.DataDia }) }; b.Itens = dados.Count(); b.End = DateTime.Now; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public override void Assign(BaseEntityDTO entity) { base.Assign(entity); ControlDTO control = entity as ControlDTO; Date = control.Date; Description = control.Description; MaxMark = control.MaxMark; }
public static TEntity ToEntity <TEntity>(this BaseEntityDTO model) where TEntity : BaseEntity { if (model == null) { throw new ArgumentNullException(nameof(model)); } return(model.Map <TEntity>()); }
public async Task <IActionResult> GetAllPaginadoAsync([FromBody] RetornoModel r) { IActionResult res = null; var b = new BaseEntityDTO <dynamic>() { Start = DateTime.Now }; try { r.ClienteID = ClienteID; var dados = await new RetornoRepository().GetAllTuple(r, UsuarioID); if (!dados.Item1.Any() && !dados.Item2.Any()) { return(NoContent()); } b.Result = new { paginas = dados.Item2.Sum(a => a.Quantidade) / r.Registros, registros = dados.Item2.Sum(a => a.Quantidade), datainicial = r.DataInicial, classificacoes = dados.Item2.OrderByDescending(a => a.Quantidade).Take(3), datafinal = r.DataFinal, retornos = dados.Item1.Select(n => new { celular = n.Celular, classificacaoio = n.ClassificacaoIOPeople, score = n.Score, retornocliente = n.RetornoCliente, dataretorno = n.DataRetorno, idcliente = n.IDCliente, texto = n.Texto, datadia = n.DataRetorno.Date, codigo = n.Codigo, carteira = n.Carteira, arquivo = n.Arquivo }) }; b.Itens = dados.Item1.Sum(a => a.Quantidade); b.End = DateTime.Now; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
public override void Assign(BaseEntityDTO entity) { base.Assign(entity); GroupDTO group = entity as GroupDTO; this.Cathedra = group.Cathedra; this.Specialization = group.Specialization; this.cathedraId = group.CathedraID; this.specializationId = group.SpecializationID; }
public async Task <IActionResult> UpdateInfo([FromBody] object o) { IActionResult res = null; var _b = new BaseEntityDTO <dynamic>() { Start = DateTime.Now }; try { var x = User.Claims.Where(k => k.Type.EndsWith("role")).ElementAt(0); switch (x.Value) { case "Fornecedor": var fornecedorid = int.Parse(User.FindFirst(a => a.Type == "fornecedorid").Value); var f = JsonConvert.DeserializeObject <FornecedorModel>(o.ToString()); await new FornecedorRepository().Update(new FornecedorModel[] { f }, fornecedorid, null); break; case "Cliente": var clienteid = int.Parse(User.FindFirst(a => a.Type == "clienteid").Value); var c = JsonConvert.DeserializeObject <ClienteModel> (o.ToString()); await new ClienteRepository().Update(new ClienteModel[] { c }, clienteid, null); break; case "Usuario": break; case "AdminOnly": break; } _b.End = DateTime.Now; _b.Itens = 1; res = Ok(_b); } catch (Exception err) { _b.End = DateTime.Now; _b.Error = (err.InnerException ?? err).Message; res = BadRequest(_b); } return(Ok(_b)); }
public async Task <IActionResult> AdicionarFornecedorCapacidadeExtraAsync([FromBody] IEnumerable <FornecedorCapacidadeExtraModel> t) { IActionResult res = null; var b = new BaseEntityDTO <IEnumerable <FornecedorCapacidadeExtraModel> >() { Start = DateTime.Now }; try { if (t == null || !t.Any()) { throw new Exception("Requisição inválida"); } var hoje = DateTime.Now.Date; foreach (var o in t) { if (o.Capacidade == 0 || o.ClienteID == 0) { throw new Exception("Requisição inválida"); } if (!o.DataInicial.HasValue || !o.DataFinal.HasValue) { throw new Exception("Data inicial e ou final não informada(s)"); } if (o.DataInicial < hoje || o.DataFinal < hoje) { throw new Exception("As datas devem ser maior ou igual a hoje"); } if (o.DataInicial > o.DataFinal) { throw new Exception($"A data final { o.DataFinal.Value.ToString("dd/MM/yyyy") } deve ser maior ou igual a data inicial { o.DataInicial.Value.ToString("dd/MM/yyyy") }"); } } await new FornecedorRepository().AdicionarFornecedorCapacidadeExtraAsync(t, FornecedorID); b.End = DateTime.Now; b.Itens = 1; res = Ok(b); } catch (Exception err) { b.End = DateTime.Now; b.Error = (err.InnerException ?? err).Message; res = BadRequest(b); } return(res); }
protected async Task <bool> DeleteItem <T>(BaseEntityDTO dto) where T : BaseEntity { var set = ctx.Set <T>(); var ent = mapper.Map <T>(dto); var item = await set.FindAsync(ent.Id); if (item == null) { return(false); } set.Remove(item); return(await ctx.SaveChangesAsync() > 0); }
public BaseModel(BaseEntityDTO entity) { this.id = entity.ID; }
public virtual void Assign(BaseEntityDTO entity) { this.id = entity.ID; }
protected abstract SaveableViewModel GetViewModel(BaseEntityDTO entity);
public static void SetSelectedEntity(DependencyObject obj, BaseEntityDTO value) { obj.SetValue(SelectedEntityProperty, value); }
private void InitializeSubjects(BaseEntityDTO entity) { unusedStudents = new ObservableCollection<StudentDTO>(); List<StudentDTO> students = ControllerInterop.Service.GetAllStudents(ControllerInterop.Session); if (PracticeTeacher != null) { UsedStudents = new ObservableCollection<StudentDTO>(PracticeTeacher.Students); foreach (StudentDTO student in students) if (PracticeTeacher.Students.Find(s => s.ID == student.ID) == null) UnusedStudents.Add(student); if (entity is InstituteDTO) { List<StudentDTO> instituteStudents; if (entity.ID > 0) instituteStudents = ControllerInterop.Service.GetInstituteStudents(ControllerInterop.Session, entity.ID); else instituteStudents = ControllerInterop.Service.GetAllStudents(ControllerInterop.Session); UsedStudents = new ObservableCollection<StudentDTO>((from s in usedStudents where instituteStudents.Find(st => st.ID == s.ID) != null select s).ToList()); UnusedStudents = new ObservableCollection<StudentDTO>((from s in unusedStudents where instituteStudents.Find(st => st.ID == s.ID) != null select s).ToList()); } else if (entity is FacultyDTO) { List<StudentDTO> facultyStudents = ControllerInterop.Service.GetFacultyStudents(ControllerInterop.Session, entity.ID); UsedStudents = new ObservableCollection<StudentDTO>((from s in usedStudents where facultyStudents.Find(st => st.ID == s.ID) != null select s).ToList()); UnusedStudents = new ObservableCollection<StudentDTO>((from s in unusedStudents where facultyStudents.Find(st => st.ID == s.ID) != null select s).ToList()); } else if (entity is CathedraDTO) { List<StudentDTO> cathedraStudents = ControllerInterop.Service.GetCathedraStudents(ControllerInterop.Session, entity.ID); UsedStudents = new ObservableCollection<StudentDTO>((from s in usedStudents where cathedraStudents.Find(st => st.ID == s.ID) != null select s).ToList()); UnusedStudents = new ObservableCollection<StudentDTO>((from s in unusedStudents where cathedraStudents.Find(st => st.ID == s.ID) != null select s).ToList()); } else if (entity is GroupDTO) { List<StudentDTO> groupStudents = ControllerInterop.Service.GetGroupStudents(ControllerInterop.Session, entity.ID); UsedStudents = new ObservableCollection<StudentDTO>((from s in usedStudents where groupStudents.Find(st => st.ID == s.ID) != null select s).ToList()); UnusedStudents = new ObservableCollection<StudentDTO>((from s in unusedStudents where groupStudents.Find(st => st.ID == s.ID) != null select s).ToList()); } UsedStudents.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(UsedStudents_CollectionChanged); UnusedStudents.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(UsedStudents_CollectionChanged); } }