public int Inserir(Foto foto) { using (var acc = new AccessControlContainer()) { try { acc.FotoSet.Add(foto); return(acc.SaveChanges()); } catch (Exception e) { throw new Exception("Erro ao tentar inserir a Foto: " + e.Message); } } }
public int Inserir(Usuario usuario) { using (var acc = new AccessControlContainer()) { try { acc.UsuarioSet.Add(usuario); return(acc.SaveChanges()); } catch (Exception e) { throw new Exception("Erro ao tentar inserir o Usuário: " + e.Message); } } }
public void Deletar(long rfid) { using (var acc = new AccessControlContainer()) { try { var foto = acc.FotoSet.Where(f => f.Rfid == rfid).SingleOrDefault(); acc.FotoSet.Remove(foto); acc.SaveChanges(); } catch (Exception e) { throw new Exception("Erro ao tentar deletar a Foto: " + e.Message); } } }
public void Deletar(long rfid) { using (var acc = new AccessControlContainer()) { try { var usuario = acc.UsuarioSet.Where(u => u.Rfid == rfid).SingleOrDefault(); acc.UsuarioSet.Remove(usuario); acc.SaveChanges(); } catch (Exception e) { throw new Exception("Erro ao tentar deletar o Usuário: " + e.Message); } } }
public Foto Atualizar(Foto foto) { using (var acc = new AccessControlContainer()) { try { var Foto = acc.FotoSet.Where(f => f.Rfid == foto.Rfid).SingleOrDefault(); Foto.Imagem = foto.Imagem; acc.SaveChanges(); return(foto); } catch (Exception e) { throw new Exception("Erro ao tentar atualizar a Foto: " + e.Message); } } }
public Usuario Atualizar(Usuario usuario) { using (var acc = new AccessControlContainer()) { try { var Usuario = acc.UsuarioSet.Where(u => u.Rfid == usuario.Rfid).SingleOrDefault(); Usuario.Nome = usuario.Nome; Usuario.Descricao = usuario.Descricao; Usuario.Telefone = usuario.Telefone; Usuario.Nascimento = usuario.Nascimento; acc.SaveChanges(); return(usuario); } catch (Exception e) { throw new Exception("Erro ao tentar atualizar o Usuário: " + e.Message); } } }