public void Atualizar(Ficha ficha) { using (var foc = new FichaOnlineContainer()) { try { var fic = foc.FichaSet.Where(f => f.Id == ficha.Id).SingleOrDefault(); var props = ficha.GetType().GetProperties(); foreach (var p in props) { if (p.Name != "Peculiaridades" && p.Name != "PropriedadesRiquezasItensArmas" && p.Name != "Usuario") { if (p.GetValue(ficha, null) != null && p.GetValue(fic, null) != null) { var value = p.GetValue(ficha, null).ToString(); if (value != p.GetValue(fic, null).ToString()) { p.SetValue(fic, p.GetValue(ficha, null), null); } } else if (p.Name == "MestreId") { fic.MestreId = ficha.MestreId; } } } foc.SaveChanges(); } catch (Exception ex) { throw new Exception("[FichaDao.Atualizar] -> " + ex.Message); } } }
public List <string> SelecionarNomesRacas(string str) { using (var foc = new FichaOnlineContainer()) { try { return(foc.FichaSet.Where(f => f.Raca.StartsWith(str)).Select(f => f.Raca).Distinct().ToList()); } catch (Exception ex) { throw new Exception("[FichaDao.SelecionarNomesRacas] -> " + ex.Message); } } }
public Ficha SelecionarPorId(int id) { using (var foc = new FichaOnlineContainer()) { try { return(foc.FichaSet.Where(f => f.Id == id).SingleOrDefault()); } catch (Exception ex) { throw new Exception("[FichaDao.SelecionarPorId] -> " + ex.Message); } } }
public List <Peculiaridade> ListarPorTipo(string tipo) { using (var foc = new FichaOnlineContainer()) { try { return(foc.PeculiaridadeSet.Where(p => p.Tipo == tipo).ToList()); } catch (Exception ex) { throw new Exception("[PeculiaridadeDao.ListarPorTipo] -> " + ex.Message); } } }
public List <string> SelecionarMestres(string str) { using (var foc = new FichaOnlineContainer()) { try { return(foc.UsuarioSet.Where(u => u.Nome.StartsWith(str) || u.Email.StartsWith(str)).Select(u => u.Nome + ", " + u.Email).ToList()); } catch (Exception ex) { throw new Exception("[UsuarioDao.SelecionarMestres] -> " + ex.Message); } } }
public Usuario SelecionarPorEmail(string email) { using (var foc = new FichaOnlineContainer()) { try { return(foc.UsuarioSet.Where(u => u.Email == email).SingleOrDefault()); } catch (Exception ex) { throw new Exception("[UsuarioDao.SelecionarPorEmail] -> " + ex.Message); } } }
public List <Usuario> Listar() { using (var foc = new FichaOnlineContainer()) { try { return(foc.UsuarioSet.ToList()); } catch (Exception ex) { throw new Exception("[UsuarioDao.Listar] -> " + ex.Message); } } }
public List <string> SelecionarNomesPeculiaridades(string term, string tipo) { using (var foc = new FichaOnlineContainer()) { try { return(foc.PeculiaridadeSet.Where(p => p.Nome.StartsWith(term) || p.Descricao.Contains(term)).Where(p => p.Tipo == tipo).Select(p => p.Nome).ToList()); } catch (Exception ex) { throw new Exception("[PeculiaridadeDao.SelecionarNomesPeculiaridades] -> " + ex.Message); } } }
public Peculiaridade SelecionarPorId(int id) { using (var foc = new FichaOnlineContainer()) { try { return(foc.PeculiaridadeSet.Where(p => p.Id == id).SingleOrDefault()); } catch (Exception ex) { throw new Exception("[PeculiaridadeDao.SelecionarPorId] -> " + ex.Message); } } }
public List <string> SelecionarDescricoesPropriedadeRiqueza(string term, string tipo) { using (var foc = new FichaOnlineContainer()) { try { return(foc.PropriedadeRiquezaItemArmaSet.Where(p => p.Descricao.StartsWith(term)).Where(p => p.Tipo == tipo).Select(p => p.Descricao).ToList()); } catch (Exception ex) { throw new Exception("[PRIADao.SelecionarDescricoesPropriedadeRiqueza] -> " + ex.Message); } } }
public List <Ficha> ListarPorMestreId(int mestreId) { using (var foc = new FichaOnlineContainer()) { try { return(foc.FichaSet.Where(f => f.MestreId == mestreId && f.UsuarioId != mestreId && f.Pontos >= 0).ToList()); } catch (Exception ex) { throw new Exception("[FichaDao.ListarPorMestreId] -> " + ex.Message); } } }
public PropriedadeRiquezaItemArma SelecionarPorId(int id) { using (var foc = new FichaOnlineContainer()) { try { return(foc.PropriedadeRiquezaItemArmaSet.Where(p => p.Id == id).SingleOrDefault()); } catch (Exception ex) { throw new Exception("[PRIADao.ListarPorId] -> " + ex.Message); } } }
public List <PropriedadeRiquezaItemArma> ListarPorFichaIdETipo(int fichaid, string tipo) { using (var foc = new FichaOnlineContainer()) { try { return(foc.PropriedadeRiquezaItemArmaSet.Where(p => p.FichaId == fichaid && p.Tipo == tipo).ToList()); } catch (Exception ex) { throw new Exception("[PRIADao.ListarPorFichaIdETipo] -> " + ex.Message); } } }
public void Inserir(Peculiaridade peculiaridade) { using (var foc = new FichaOnlineContainer()) { try { foc.PeculiaridadeSet.Add(peculiaridade); foc.SaveChanges(); } catch (Exception ex) { throw new Exception("[PeculiaridadeDao.Inserir] -> " + ex.Message); } } }
public void Inserir(PropriedadeRiquezaItemArma pria) { using (var foc = new FichaOnlineContainer()) { try { foc.PropriedadeRiquezaItemArmaSet.Add(pria); foc.SaveChanges(); } catch (Exception ex) { throw new Exception("[PRIADao.Inserir] -> " + ex.Message); } } }
public void Inserir(Usuario usuario) { using (var foc = new FichaOnlineContainer()) { try { usuario.DataCadastro = DateTime.Now.ToString(); foc.UsuarioSet.Add(usuario); foc.SaveChanges(); } catch (Exception ex) { throw new Exception("[UsuarioDao.Inserir] -> " + ex.Message); } } }
public Usuario SelecionarPorId(int?id) { using (var foc = new FichaOnlineContainer()) { try { if (id != null) { return(foc.UsuarioSet.Where(u => u.Id == id).SingleOrDefault()); } return(null); } catch (Exception ex) { throw new Exception("[UsuarioDao.SelecionarPorId] -> " + ex.Message); } } }
public void Atualizar(Peculiaridade peculiaridade) { using (var foc = new FichaOnlineContainer()) { try { var pec = foc.PeculiaridadeSet.Where(p => p.Id == peculiaridade.Id).SingleOrDefault(); pec.Nome = peculiaridade.Nome; pec.Descricao = peculiaridade.Descricao; pec.Teste = peculiaridade.Teste; foc.SaveChanges(); } catch (Exception ex) { throw new Exception("[PeculiaridadeDao.Atualizar] -> " + ex.Message); } } }
public void Inserir(Ficha ficha) { using (var foc = new FichaOnlineContainer()) { try { if (ficha.Nota == null) { ficha.Nota = ""; } foc.FichaSet.Add(ficha); foc.SaveChanges(); } catch (Exception ex) { throw new Exception("[FichaDao.Inserir] -> " + ex.Message); } } }
public void Atualizar(PropriedadeRiquezaItemArma pria) { using (var foc = new FichaOnlineContainer()) { try { var prop = foc.PropriedadeRiquezaItemArmaSet.Where(p => p.Id == pria.Id).SingleOrDefault(); prop.Nome = pria.Nome; prop.Subtipo = pria.Subtipo; prop.PesoQuantidade = pria.PesoQuantidade; prop.Descricao = pria.Descricao; prop.ValorDano = pria.ValorDano; foc.SaveChanges(); } catch (Exception ex) { throw new Exception("[PRIADao.Atualizar] -> " + ex.Message); } } }