Exemplo n.º 1
0
        public async Task <ActionResult <CharityResponseDto> > GetCharityRestrictedById(Guid id)
        {
            CharityResponseDto charityDto = await CharitableEntityApplication.GetCharity(c => c.Id.Equals(id), true);

            if (charityDto == null)
            {
                ErrorMessage error = new ErrorMessage((int)HttpStatusCode.NotFound, $"A entidade beneficente, {id}, não foi encontrada.");
                return(NotFound(error));
            }

            return(Ok(charityDto));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <IEnumerable <ApprovalResponseDto> > > GetCharityApproval(Guid id)
        {
            CharityResponseDto charityDto = await CharitableEntityApplication.GetCharity(c => c.Id.Equals(id), true);

            if (charityDto == null)
            {
                ErrorMessage error = new ErrorMessage((int)HttpStatusCode.NotFound, $"A entidade beneficente, {id}, não foi encontrada.");
                return(NotFound(error));
            }

            var approvals = await CharitableEntityApplication.GetCharityApprovalResponseDto(a => a.CharitableEntityId.Equals(id));

            return(Ok(approvals));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> DeleteCharity(Guid id)
        {
            // Check if the donor exists
            CharityResponseDto charityDto = await CharitableEntityApplication.GetCharity(c => c.Id.Equals(id));

            if (charityDto == null)
            {
                ErrorMessage error = new ErrorMessage((int)HttpStatusCode.NotFound, $"A entidade beneficente, {id}, não foi encontrada.");
                return(NotFound(error));
            }

            await CharitableEntityApplication.DeleteCharity(id);

            return(NoContent());
        }
Exemplo n.º 4
0
        public async Task <ActionResult <CharityResponseDto> > GetCharityById(Guid id)
        {
            CharityResponseDto charityDto = await CharitableEntityApplication.GetCharity(c => c.Id.Equals(id), true);

            if (charityDto == null)
            {
                ErrorMessage error = new ErrorMessage((int)HttpStatusCode.NotFound, $"A entidade beneficente, {id}, não foi encontrada.");
                return(NotFound(error));
            }
            else if (!charityDto.Active || string.IsNullOrWhiteSpace(charityDto.Approver))
            {
                if (charityDto.Status != ApproverStatus.PENDING_DATA.ToString())
                {
                    ErrorMessage error = new ErrorMessage((int)HttpStatusCode.BadRequest, $"A entidade beneficente, {id}, está inativa.");
                    return(BadRequest(error));
                }
            }

            return(Ok(charityDto));
        }
Exemplo n.º 5
0
        public async Task <ActionResult <CharityInfoItemResponseDto> > GetCharityItem(Guid id)
        {
            CharityResponseDto charityDto = await CharitableEntityApplication.GetCharity(c => c.Id.Equals(id), true);

            if (charityDto == null)
            {
                ErrorMessage error = new ErrorMessage((int)HttpStatusCode.NotFound, $"A entidade beneficente, {id}, não foi encontrada.");
                return(NotFound(error));
            }


            if (charityDto.Information == null)
            {
                ErrorMessage error = new ErrorMessage((int)HttpStatusCode.NotFound, $"As informações complementares da entidade beneficente não foram cadastradas.");
                return(NotFound(error));
            }

            var charityInfoItems = await CharitableInformationApplication.GetCharityInfoItem(p => p.CharitableInformationId == charityDto.Information.Id);

            return(Ok(charityInfoItems));
        }