diff --git a/Retroactiune.WebAPI/Controllers/Admin/RetroactiuneController.cs b/Retroactiune.WebAPI/Controllers/Admin/RetroactiuneController.cs deleted file mode 100644 index 63e7390..0000000 --- a/Retroactiune.WebAPI/Controllers/Admin/RetroactiuneController.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Microsoft.AspNetCore.Mvc; -using Retroactiune.Models; - -namespace Retroactiune.Controllers.Admin -{ - [ApiController] - [Route("api/v1/[controller]")] - public class RetroActiune : ControllerBase - { - - [HttpDelete("{id}")] - public NoContentResult Delete(long id) - { - return NoContent(); - } - - - [HttpPost] - public BasicResponse Post() - { - return new BasicResponse() - { - Message = "post retroactiune" - }; - } - - [HttpGet("{id}")] - public BasicResponse Get(long id) - { - return new BasicResponse() - { - Message = "hwlo" - }; - } - - [HttpGet] - public IEnumerable List() - { - return Enumerable.Range(1, 5).Select(i => - new BasicResponse() - { - Message = "hwlo" - } - ); - } - } -} \ No newline at end of file diff --git a/Retroactiune.WebAPI/Controllers/FeedbackReceiverController.cs b/Retroactiune.WebAPI/Controllers/FeedbackReceiverController.cs new file mode 100644 index 0000000..38e7ea6 --- /dev/null +++ b/Retroactiune.WebAPI/Controllers/FeedbackReceiverController.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using AutoMapper; +using Microsoft.AspNetCore.Mvc; +using Retroactiune.Models; +using Retroactiune.Services; + +namespace Retroactiune.Controllers +{ + [ApiController] + [Route("api/v1/[controller]")] + public class FeedbackReceiverController : ControllerBase + { + private readonly FeedbackReceiverService _service; + private readonly IMapper _mapper; + + public FeedbackReceiverController(FeedbackReceiverService service, IMapper mapper) + { + _service = service; + _mapper = mapper; + } + + [HttpDelete("{id}")] + public NoContentResult Delete(long id) + { + // delete feedback item. + return NoContent(); + } + + + [HttpPost] + public async Task Post(IEnumerable items) + { + var mappedItems = items.ToList().Select(i => + { + var result = _mapper.Map(i); + result.CreatedAt = DateTime.UtcNow; + return result; + }); + + await _service.CreateMany(mappedItems); + + return new BasicResponse() + { + Message = "Items created successfully!" + }; + } + + [HttpGet("{id}")] + public BasicResponse Get(long id) + { + // get feedback item from db + return new BasicResponse() + { + Message = "hwlo" + }; + } + + [HttpGet] + public IEnumerable List() + { + // list all feedback items. + return Enumerable.Range(1, 5).Select(i => + new BasicResponse() + { + Message = "hwlo" + } + ); + } + } +} \ No newline at end of file