ahmed salah

ahmed salah

  • 1.1k
  • 669
  • 42.4k

How to call web api on another layer as asp.net mvc application ?

Apr 15 2024 6:39 AM

I work as asp.net core application my issue  I need to create web api on separate layer

and another layer will be for view 

 

so how to make web page as view on another layer call this web api

are this possible

using Contracts;
using Microsoft.AspNetCore.Mvc;
using Services.Contracts;
using Shared.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TEAA.Presentation.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class FAQsController : ControllerBase
    {
        private ILoggerManager _logger;
        private readonly IServiceManager _serviceManager;

        public FAQsController(ILoggerManager logger, IServiceManager serviceManager)
        {
            _logger = logger;
            _serviceManager = serviceManager;
        }


        
        public ActionResult<FAQDto> GetFAQs()
        {
            var FAQs = _serviceManager.FAQService.GetFAQs( trackChanges: false);
            return Ok(FAQs);
        }
    }
}

 


Answers (4)