API
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MailController.cs 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Http;
  6. using Microsoft.AspNetCore.Mvc;
  7. using UnivateProperties_API.Model.Communication;
  8. using UnivateProperties_API.Repository.Communication;
  9. namespace UnivateProperties_API.Controllers.Communication
  10. {
  11. [Route("api/[controller]")]
  12. [ApiController]
  13. public class MailController : ControllerBase
  14. {
  15. private readonly IMailRepository _repo;
  16. public MailController(IMailRepository repo)
  17. {
  18. _repo = repo;
  19. }
  20. [HttpPost("{id}")]
  21. public IActionResult Post(int id, [FromBody] MailModel mm)
  22. {
  23. try
  24. {
  25. switch (id)
  26. {
  27. case 0:
  28. _repo.ContactUs(mm);
  29. break;
  30. case 1:
  31. _repo.EnquireNow(mm);
  32. break;
  33. }
  34. return new OkResult();
  35. }
  36. catch
  37. {
  38. return new BadRequestResult();
  39. }
  40. }
  41. }
  42. }