public ProfissionalServico Cadastrar(ProfissionalServico obj, string token) { try { if (SeguracaServ.validaToken(token)) { if (obj.ID == 0) { obj.DataCriacao = DateTime.UtcNow; obj.DataEdicao = DateTime.UtcNow; obj.ID = _Rep.Add(obj); } else { obj.DataEdicao = DateTime.UtcNow; _Rep.Update(obj); } return(obj); } else { throw new Exception("Token inválido!"); } } catch (Exception ex) { throw new Exception("Erro ao efetuar requisição!"); } }
public async Task <ProfissionalFormacao> SaveAsync(ProfissionalFormacao entity, string token) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { if (entity.ID == 0) { entity.DataCriacao = DateTime.UtcNow; entity.DataEdicao = DateTime.UtcNow; entity.Ativo = true; entity.ID = _repository.Add(entity); return(entity); } else { entity.DataEdicao = DateTime.UtcNow; _repository.Update(entity); return(entity); } } else { throw new Exception("Token inválido!"); } } catch (Exception e) { throw new Exception("Erro ao efetuar requisição!", e); } }
public async Task <Telefone> SaveAsync(Telefone entity, string token) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { if (entity.ID == 0) { entity.DataCriacao = DateTime.UtcNow; entity.DataEdicao = DateTime.UtcNow; entity.Ativo = true; entity.ID = _tfRepository.Add(entity); } else { entity = await UpdateAsync(entity, token); } return(entity); } else { throw new Exception("Token inválido!"); } } catch (Exception e) { throw new Exception("Erro ao efetuar requisição!", e); } }
public int Cadastrar(Avaliacao obj, string token) { try { if (SeguracaServ.validaToken(token)) { if (obj.ID == 0) { obj.DataCriacao = DateTime.UtcNow; obj.DataEdicao = DateTime.UtcNow; return(new AvaliacaoRep().Add(obj)); } else { obj.DataEdicao = DateTime.UtcNow; new AvaliacaoRep().Update(obj); return(1); } } else { throw new Exception("Token inválido!"); } } catch (Exception ex) { throw new Exception("Erro ao efetuar requisição!"); } }
public async Task <ProfissionalServico> GetByUserIdAsync(int idCliente, string token, int userId) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { lock (_lock) { var result = _pfRepository.GetSingle(p => p.IdCliente.Equals(idCliente) && p.IdUsuario.Equals(userId)); var pServico = _servicoRep.GetSingle(x => x.CodigoExterno.Equals(result.ID)); var servico = _sRep.GetSingle(s => s.ID.Equals(pServico.ServicoId)); pServico.Servico = servico; pServico.Profissional = result; return(pServico); } } else { throw new Exception("Token inválido."); } } catch (Exception e) { throw new Exception("Erro ao efetuar requisição!", e); } }
public bool Inserir(IEnumerable <Avaliacao> obj, string token) { try { if (SeguracaServ.validaToken(token)) { foreach (var item in obj) { if (item.ID == 0) { item.DataCriacao = DateTime.UtcNow; item.DataEdicao = DateTime.UtcNow; var r = new AvaliacaoRep().Add(item); } else { item.DataEdicao = DateTime.UtcNow; new AvaliacaoRep().Update(item); } } return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
public async Task <IEnumerable <ProfissionalServico> > GetByIdListAsync(int idCliente, string token, IEnumerable <int> ids) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { var result = _pfRepository.GetList(p => ids.Contains(p.ID)); var pIds = result.Select(x => x.ID); var pServicos = _servicoRep.GetList(x => pIds.Contains(x.UsuarioId)); var sIds = pServicos.Select(x => x.ServicoId); var servicos = _sRep.GetList(s => sIds.Contains(s.ID)); foreach (var item in pServicos) { item.Profissional = result.FirstOrDefault(p => p.ID.Equals(item.UsuarioId)); item.Servico = servicos.FirstOrDefault(s => s.ID.Equals(item.ServicoId)); } return(pServicos); } else { throw new Exception("Token inválido."); } } catch (Exception e) { throw new Exception("Erro ao efetuar requisição!", e); } }
public async Task <IEnumerable <Categoria> > GetAllAsync(int idCliente, string token) { try { await SeguracaServ.ValidaTokenAsync(token); var result = _repository.GetList(c => c.IdCliente.Equals(idCliente)); return(result); } catch (Exception e) { throw new Exception("Não foi possível listar as categorias disponíveis.", e); } }
public async Task <IList <ProfissionalServico> > GetAll(string token, int idCliente) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { return(_Rep.GetList(ps => ps.IdCliente.Equals(idCliente))); } else { throw new Exception("Token inválido!"); } } catch (Exception) { throw new Exception("Erro ao efetuar requisição!"); } }
public async Task <List <Dominio.Entidades.Servico> > GetByServicoTipoId(int idTipo, string token, int idCliente) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { return(await new ServicoRep().GetByServicoTipoId(idTipo, idCliente)); } else { throw new Exception("Requisição inválida"); } } catch (Exception) { throw new Exception("Erro ao efetuar requisição!"); } }
public List <Dominio.Entidades.Servico> GetByProfissional(int idProfissional, string token, int idCliente) { try { if (SeguracaServ.validaToken(token)) { return(Rep.GetByProfissional(idProfissional, idCliente)); } else { throw new Exception("Requisição inválida"); } } catch (Exception) { throw new Exception("Erro ao efetuar requisição!"); } }
public void Remover(ProfissionalServico obj, string token) { try { if (SeguracaServ.validaToken(token)) { _Rep.Remove(obj); } else { throw new Exception("Token inválido!"); } } catch (Exception) { throw new Exception("Erro ao efetuar requisição!"); } }
public async Task <IList <ServicoTipo> > Get(string token, int idCliente) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { return(new ServicoTipoRep().GetList(st => st.IdCliente.Equals(idCliente))); } else { throw new Exception("Requisição inválida"); } } catch (Exception) { return(new List <ServicoTipo>()); } }
public async Task <List <Avaliacao> > GetByAvaliado(int idAvaliado, string token, int idCliente) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { return(await new AvaliacaoRep().GetByAvaliado(idAvaliado, idCliente)); } else { throw new Exception("Token inválido!"); } } catch (Exception ex) { throw new Exception("Erro ao efetuar requisição!"); } }
public async Task <IList <Avaliacao> > GetAllAsync(string token, int idCliente) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { return(new AvaliacaoRep().GetList(a => a.IdCliente.Equals(idCliente))); } else { throw new Exception("Token inválido!"); } } catch (Exception ex) { throw new Exception("Erro ao efetuar requisição!"); } }
public async Task RemoveAsync(ProfissionalFormacao entity, string token) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { _repository.Remove(entity); } else { throw new Exception("Token inválido!"); } } catch (Exception e) { throw new Exception("Erro ao efetuar requisição!", e); } }
public async Task <ServicoTipo> Get(int id, string token, int idCliente) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { return(await new ServicoTipoRep().GetByIdAsync(id, idCliente)); } else { throw new Exception("Requisição inválida"); } } catch (Exception) { throw new Exception("Erro ao efetuar requisição!"); } }
public async Task <ProfissionalFavorito> SaveAsync(ProfissionalFavorito entity, string token) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { if (_profissionalFavoritoRep.GetSingle(x => x.ProfissionalId == entity.ProfissionalId && x.IdEmpresa == entity.IdEmpresa && x.IdCliente == entity.IdCliente) == null) { entity.ID = _profissionalFavoritoRep.Add(entity); } return(entity); } else { throw new Exception("Token inválido!"); } return(default);
public async Task <Dominio.Entidades.Profissional> GetByIdAsync(int entityId, int idCliente, string token) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { var result = _pfRepository.GetList(p => p.IdCliente.Equals(idCliente) && p.ID.Equals(entityId)).SingleOrDefault(); return(result); } else { throw new Exception("Token inválido."); } } catch (Exception e) { throw new Exception("Erro ao efetuar requisição!", e); } }
public async Task <IList <Dominio.Entidades.Servico> > Get(string token, int idCliente) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { var t = new ServicoRep().GetList(s => s.IdCliente.Equals(idCliente)); return(t); } else { throw new Exception("Requisição inválida"); } } catch (Exception ex) { throw new Exception("Erro ao efetuar requisição!"); } }
public async Task <IEnumerable <ProfissionalFormacao> > GetAllAsync(int idCliente, string token) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { var result = _repository.GetList(f => f.IdCliente.Equals(idCliente)); return(result); } else { throw new Exception("Token inválido!"); } } catch (Exception e) { throw new Exception("Erro ao efetuar requisição!", e); } }
public void Alterar(ProfissionalServico obj, string token) { try { if (SeguracaServ.validaToken(token)) { obj.DataEdicao = DateTime.UtcNow; _Rep.Update(obj); } else { throw new Exception("Token inválido!"); } } catch (Exception ex) { throw new Exception("Erro ao efetuar requisição!"); } }
public async Task <IEnumerable <Telefone> > GetAllAsync(int idCliente, string token) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { var telefones = _tfRepository.GetList(e => e.IdCliente.Equals(idCliente)); return(telefones); } else { throw new Exception("Token inválido!"); } } catch (Exception e) { throw new Exception("Erro ao efetuar requisição!", e); } }
public async Task <ProfissionalFormacao> GetByIdAsync(int entityId, int idCliente, string token) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { var formacao = _repository.GetList(f => f.ID.Equals(entityId) && f.IdCliente.Equals(idCliente)).SingleOrDefault(); return(formacao); } else { throw new Exception("Token inválido!"); } } catch (Exception e) { throw new Exception("Erro ao efetuar requisição!", e); } }
public async Task <Telefone> UpdateAsync(Telefone entity, string token) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { entity.DataEdicao = DateTime.UtcNow; _tfRepository.Update(entity); return(entity); } else { throw new Exception("Token inválido!"); } } catch (Exception e) { throw new Exception("Erro ao efetuar requisição!", e); } }
public async Task <Telefone> GetByIdAsync(int entityId, int idCliente, string token) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { var telefone = _tfRepository.GetList(e => e.IdCliente.Equals(idCliente) && e.ID.Equals(entityId)).SingleOrDefault(); return(telefone); } else { throw new Exception("Token inválido!"); } } catch (Exception e) { throw new Exception("Erro ao efetuar requisição!", e); } }
public async Task <Dominio.Entidades.Profissional> UpdateAsync(Dominio.Entidades.Profissional entity, string token) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { entity.DataEdicao = DateTime.UtcNow; _pfRepository.Update(entity); return(entity); } else { throw new Exception("Token inválido."); } } catch (Exception e) { throw new Exception("Erro ao efetuar requisição!", e); } }
public async Task <Dominio.Entidades.Profissional> SaveAsync(Dominio.Entidades.Profissional entity, string token) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { if (entity.ID == 0) { entity.DataCriacao = DateTime.UtcNow; entity.DataEdicao = DateTime.UtcNow; //entity.Ativo = true; var pfId = _pfRepository.Add(entity); if (entity.Endereco != null) { entity.Endereco.ProfissionalId = pfId; } if (entity.Telefone != null) { entity.Telefone.ProfissionalId = pfId; } } else { entity = await UpdateAsync(entity, token); } return(entity); } else { throw new Exception("Token inválido!"); } } catch (Exception e) { throw new Exception("Erro ao efetuar requisição!", e); } }
public async Task <IEnumerable <ProfissionalServico> > GetProfissionalServicos(int idCliente, string token) { try { if (await SeguracaServ.ValidaTokenAsync(token)) { lock (_lock) { var profissionais = _pfRepository.GetList(p => p.IdCliente.Equals(idCliente)); var pIds = new List <int>(); foreach (var item in profissionais) { pIds.Add(item.ID); } var pServicos = _servicoRep.GetList(x => pIds.Contains(Convert.ToInt32(x.CodigoExterno))); var sIds = pServicos.Select(x => x.ServicoId); var servicos = _sRep.GetList(s => sIds.Contains(s.ID)); foreach (var item in pServicos) { item.Profissional = profissionais.FirstOrDefault(p => p.ID.Equals(item.CodigoExterno)); item.Servico = servicos.FirstOrDefault(s => s.ID.Equals(item.ServicoId)); } return(pServicos); } } else { throw new Exception("Token inválido!"); } } catch (Exception e) { throw new Exception("Erro ao efetuar requisição!", e); } }