public T Create(T entity) { try { _entity.Add(entity); context.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw; } catch (DbUpdateException) { throw; } catch (Exception) { /* * Para remover o warning na versão aspnet core 5.0, que diz que * os exceptions devem ser tratados explicitadamente e não repassados no catch. * warning CA2200 = Gerar novamente uma exceção detectada altera as informações de pilha * throw ex; */ throw; } return(entity); }
public User RefreshUserInfo(User user) { if (!_context.Users.Any(u => u.Id == user.Id)) { return(null); } var userEntity = _context.Users.FirstOrDefault(u => u.Id == user.Id); try { _context.Entry(userEntity).CurrentValues.SetValues(user); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw; } catch (DbUpdateException) { throw; } catch (Exception) { /* * Para remover o warning na versão aspnet core 5.0, que diz que * os exceptions devem ser tratados explicitadamente e não repassados no catch. * warning CA2200 = Gerar novamente uma exceção detectada altera as informações de pilha * throw ex; */ throw; } return(userEntity); }
public User RefreshUserInfo(User user) { if (!_context.Users.Any(p => p.Id.Equals(user.Id))) { return(null); } var result = _context.Users.SingleOrDefault(p => p.Id.Equals(user.Id)); if (result != null) { try { _context.Entry(result).CurrentValues.SetValues(user); _context.SaveChanges(); return(result); } catch (Exception) { throw; } } return(result); }
public RedirectToActionResult NewBook(string title) { Book book = new Book(title); db.Books.Add(book); db.SaveChanges(); return(RedirectToAction(actionName: "All", controllerName: "Book")); }
public Device AddDevice(long id, Device device) { Client client = GetClient(id); client.Devices += $"[{device.Id}]"; _context.Entry(client).CurrentValues.SetValues(client); _context.SaveChanges(); return(device); }
public MonsterModel Create(MonsterModel monster) { try{ _context.Add(monster); _context.SaveChanges(); }catch (Exception e) { throw e; } return(monster); }
public T Create(T item) { try { dataset.Add(item); _context.SaveChanges(); return(item); } catch (Exception) { throw; } }
public ActionModel Create(ActionModel action) { try{ _context.Add(action); _context.SaveChanges(); }catch (Exception e) { throw e; } return(action); }
public Person Create(Person person) { try { _context.Add(person); _context.SaveChanges(); } catch (Exception ex) { throw ex; } return(person); }
public T Create(T item) { try { dataset.Add(item); mySQLContext.SaveChanges(); } catch (Exception ex) { throw ex; } return(item); }
public bool RevokeToken(string Username) { var employee = _context.Employees.SingleOrDefault(e => (e.Username == Username)); if (employee == null) { return(false); } employee.RefreshToken = null; _context.SaveChanges(); return(true); }
public bool RevokeToken(string userName) { var user = _context.Users.SingleOrDefault(u => (u.UserName == userName)); if (user is null) { return(false); } user.RefreshToken = null; _context.SaveChanges(); return(true); }
/// <summary> /// Criar/Inserir um registro de T no banco de dados /// </summary> /// <param name="entity"></param> /// <returns>Retorna o resultado da inserção e seu respectivo codigo</returns> public T Create(T entity) { try { dataset.Add(entity); _context.SaveChanges(); } catch (Exception) { throw; } return(entity); }
public Usuario Create(Usuario usuario) { try { _context.Add(usuario); _context.SaveChanges(); } catch (Exception ex) { throw ex; } return(usuario); }
public Domain Create(Domain domain) { try { _context.Add(domain); _context.SaveChanges(); } catch (Exception ex) { throw ex; } return(domain); }
public Group Create(Group group) { try { _context.Add(group); _context.SaveChanges(); } catch (Exception ex) { throw ex; } return(group); }
public Livro Create(Livro livro) { try { _context.Add(livro); _context.SaveChanges(); } catch (Exception ex) { throw ex; } return(livro); }
public T Create(T entity) { try { _dbSet.Add(entity); _mySQLContext.SaveChanges(); return(entity); } catch (Exception ex) { throw ex; } }
public Profile Create(Profile profile) { try { _context.Add(profile); _context.SaveChanges(); } catch (Exception ex) { throw ex; } return(profile); }
public User Create(User user) { try { _context.Add(user); _context.SaveChanges(); } catch (Exception ex) { throw ex; } return(user); }
public T Create(T Item) { try { dataSet.Add(Item); _mySQLContext.SaveChanges(); } catch (Exception ex) { throw ex; } return(Item); }
public Escola Create(Escola escola) { try { _context.Add(escola); _context.SaveChanges(); } catch (Exception ex) { throw ex; } return(escola); }
public Book Create(Book book) { try { _context.Add(book); _context.SaveChanges(); } catch (Exception) { throw; } return(book); }
public Aluno Create(Aluno aluno) { try { _context.Add(aluno); _context.SaveChanges(); } catch (Exception ex) { throw ex; } return(aluno); }
public Vehicle Create(Vehicle vehicle) { try { _context.Add(vehicle); _context.SaveChanges(); } catch (Exception) { throw; } return(vehicle); }
public Client Create(Client client) { try { _context.Add(client); _context.SaveChanges(); } catch (Exception) { throw; } return(client); }
public Pessoa Create(Pessoa pessoa) { try { _context.Add(pessoa); _context.SaveChanges(); } catch (Exception) { throw; } return(pessoa); }
public Turma Create(Turma turma) { try { _context.Add(turma); _context.SaveChanges(); } catch (Exception ex) { throw ex; } return(turma); }
public Sinistro Create(Sinistro sinistro) { try { _context.Add(sinistro); _context.SaveChanges(); } catch (Exception ex) { throw ex; } return(sinistro); }
public T Add(T item) { try { dataSet.Add(item); _context.SaveChanges(); return(item); } catch (Exception ex) { throw ex; } }