Beispiel #1
0
        public async Task <CustomResponse <T> > Remover(Guid Id, Guid UserId)
        {
            var _response = new CustomResponse <T>();

            try
            {
                T _entity = _contextDominio.Set <T>().Find(Id);
                _contextDominio.Remove <T>(_entity);
                await _contextDominio.SaveChangesAsync();

                _response.Message    = "Remoção";
                _response.StatusCode = StatusCodes.Status200OK;

                await GerarLog(_response.Message, typeof(T).Name, UserId);
            }
            catch (Exception ex)
            {
                _response.Message = ex.Message;
                Error.LogError(ex);
            }

            return(_response);
        }
Beispiel #2
0
        public async Task <CustomResponse <IList <Cidade> > > GetByEstado(Guid estadoId)
        {
            var _response = new CustomResponse <IList <Cidade> >();

            try
            {
                _response.Result = await _contextDominio.Set <Cidade>().Include(e => e.Estado).Where(x => x.Estado.EstadoId == estadoId)
                                   .Select(s => new Cidade {
                    CidadeId = s.CidadeId, Nome = s.Nome, Ativo = s.Ativo
                }).ToListAsync();

                _response.Message    = "Sucesso";
                _response.StatusCode = StatusCodes.Status302Found;
            }
            catch (Exception ex)
            {
                _response.Message = ex.InnerException.Message;
                Error.LogError(ex);
            }

            return(_response);
        }