public bool Update(HardwareDeSalaModel entity, int idUsuario) { try { var hardware = GetByMAC(entity.MAC, idUsuario); if (hardware != null && hardware.Id != entity.Id) { throw new ServiceException("Já existe um dispositivo com esse endereço MAC"); } if (entity.TipoHardwareId == TipoHardwareModel.CONTROLADOR_DE_SALA) { hardware = GetByIp(entity.Ip, idUsuario); if (hardware != null && hardware.Id != entity.Id) { throw new ServiceException("Já existe um dispositivo com esse endereço IP"); } } var x = _context.Hardwaredesala.Where(tu => tu.Id == entity.Id).FirstOrDefault(); if (x != null) { _context.Update(SetEntity(entity, x)); return(_context.SaveChanges() == 1); } } catch (Exception e) { throw e; } return(false); }
public bool Update(UsuarioOrganizacaoModel entity) { var x = _context.Usuarioorganizacao.Where(uo => uo.Id == entity.Id).FirstOrDefault(); if (x != null) { _context.Update(SetEntity(entity)); return(_context.SaveChanges() == 1 ? true : false); } return(false); }
public bool Update(MonitoramentoModel model) { try { _context.Update(SetEntity(model)); return(_context.SaveChanges() == 1); } catch (Exception) { throw new ServiceException("Houve um problema ao tentar fazer monitoramento da sala, por favor tente novamente em alguns minutos!"); } }
public bool Update(TipoHardwareModel entity) { var x = _context.Tipohardware.Where(th => th.Id == entity.Id).FirstOrDefault(); if (x != null) { _context.Update(SetEntity(entity, x)); return(_context.SaveChanges() == 1 ? true : false); } return(false); }
public bool Update(HorarioSalaModel entity) { var x = _context.Horariosala.Where(th => th.Id == entity.Id).FirstOrDefault(); if (x != null) { _context.Update(SetEntity(entity, x)); return(_context.SaveChanges() == 1); } return(false); }
public bool Update(TipoUsuarioModel entity) { var x = _context.Tipousuario.Where(tu => tu.Id == entity.Id).FirstOrDefault(); if (x != null) { _context.Update(SetEntity(entity, x)); return(_context.SaveChanges() == 1 ? true : false); } return(false); }
public bool Update(SalaModel entity) { try { var x = _context.Sala.Where(s => s.Id == entity.Id).FirstOrDefault(); if (x != null) { _context.Update(SetEntity(entity, x)); return(_context.SaveChanges() == 1 ? true : false); } } catch (Exception e) { throw new ServiceException("Houve um problema ao atualizar registro, tente novamente em alguns minutos"); } return(false); }
public bool Update(BlocoModel entity) { try { var bloco = GetByTitulo(entity.Titulo, entity.OrganizacaoId); if (bloco != null && bloco.Id != entity.Id) { throw new ServiceException("Essa organização já possui um bloco com esse nome"); } var x = _context.Bloco.Where(b => b.Id == entity.Id).FirstOrDefault(); if (x != null) { _context.Update(SetEntity(entity, x)); return(_context.SaveChanges() == 1 ? true : false); } } catch (Exception e) { throw e; } return(false); }
public bool Update(SalaParticularModel entity) { if (VerificaSalaExclusivaExistente(entity.Id, entity.UsuarioId, entity.SalaId)) { throw new ServiceException("Atualização não pode ser concluida pois este usuário já esta associado a essa sala em outro registro!."); } try { var x = _context.Salaparticular.Where(th => th.Id == entity.Id).FirstOrDefault(); if (x != null) { _context.Update(SetEntity(entity, x)); return(_context.SaveChanges() == 1 ? true : false); } } catch (Exception e) { throw e; } return(false); }
public bool Update(PlanejamentoModel entity) { using (var transaction = _context.Database.BeginTransaction()) { try { if (!(DateTime.Compare(entity.DataFim, entity.DataInicio) > 0 && TimeSpan.Compare(entity.HorarioFim, entity.HorarioInicio) == 1)) { throw new ServiceException("Suas Datas/Horarios possuem inconsistências, corrija-os e tente novamente"); } _context.Update(SetEntity(entity, new Planejamento())); var save = _context.SaveChanges() == 1 ? true : false; transaction.Commit(); return(save); } catch (Exception e) { transaction.Rollback(); throw e; } } }
public bool Update(OrganizacaoModel entity) { try { var empresa = GetByCnpj(entity.Cnpj); if (empresa != null && empresa.Id != entity.Id) { throw new ServiceException("Organização não pode ser removida pois ainda existem usuários ou blocos associados a ela!"); } var x = _context.Organizacao.Where(o => o.Id == entity.Id).FirstOrDefault(); if (x != null) { _context.Update(SetEntity(entity, x)); return(_context.SaveChanges() == 1 ? true : false); } } catch (Exception e) { throw e; } return(false); }