public async Task <IActionResult> GetGuaranteeByHiDee([FromForm] GuarantorDto guarantorDto)
        {
            var guarantors = await _guarantorService.GetGuaranteeByHiDee(guarantorDto);

            var guarantorDtos = _mapper.Map <IList <GuarantorDto> >(guarantors);

            return(Ok(guarantorDtos));
        }
示例#2
0
        public async Task <IList <Guarantor> > GetGuaranteeByHiDee(GuarantorDto guarantorDto)
        {
            var user = await _context.Users.Where(x => x.HiDee == guarantorDto.UserHiDee).FirstOrDefaultAsync();

            if (user.HiDee.Equals(GlobalVariables.BaseKey()))
            {
                return(null);
            }
            else
            {
                return(await _context.Guarantors.Where(x => x.GuaranteeEmail == user.Email)
                       .OrderByDescending(x => x.DateAdded).ToListAsync());
            }
        }
        public async Task <IActionResult> Add([FromForm] GuarantorDto guarantorDto)
        {
            try
            {
                var guarantor      = _mapper.Map <Guarantor>(guarantorDto);
                var addedGuarantor = await _guarantorService.Add(guarantor);

                return(Ok(addedGuarantor));
            }
            catch (AppException ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public async Task <IActionResult> Delete([FromForm] GuarantorDto guarantorDto)
        {
            await _guarantorService.Delete(guarantorDto.Id);

            return(Ok());
        }