12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using Microsoft.AspNetCore.Mvc;
- using RestSharp;
- using UnivateProperties_API.Model.Communication;
- using UnivateProperties_API.Repository.Communication;
-
- namespace UnivateProperties_API.Controllers.Communication
- {
- [Route("api/[controller]")]
- [ApiController]
- public class MailController : ControllerBase
- {
- private readonly IMailRepository _repo;
- public MailController(IMailRepository repo)
- {
- _repo = repo;
- }
-
- [HttpPost("{id}")]
- public IActionResult Post(int id, [FromBody] MailModel mm)
- {
- try
- {
- switch (id)
- {
- case 0:
- _repo.ContactUs(mm);
- break;
- case 1:
- _repo.EnquireNow(mm);
- break;
- }
- return new OkResult();
- }
- catch
- {
- return new BadRequestResult();
- }
- }
-
- [HttpPost("mailrecipient")]
- public IActionResult AddMailRecipient([FromBody] MailRecipient rec)
- {
- try
- {
- _repo.AddRecipient(rec);
- return new OkResult();
- }
- catch
- {
- return new BadRequestResult();
- }
-
- }
-
- [HttpGet("mailrecipients")]
- public IActionResult GetMailRecipients()
- {
- var recipients = _repo.GetMailRecipients();
- return new OkObjectResult(recipients);
- }
-
- [HttpGet("getContactLog")]
- public IActionResult GetContactUsLog()
- {
- var recipients = _repo.GetContactUsLog();
- return new OkObjectResult(recipients);
- }
-
- [HttpGet("getEnquireLog")]
- public IActionResult GetEnquireNowLog()
- {
- var recipients = _repo.GetEnquireNowLog();
- return new OkObjectResult(recipients);
- }
-
- [HttpGet("mailrecipient/{id}")]
- public IActionResult GetRecipientById(int id)
- {
- var recipient = _repo.GetMailRecipientById(id);
- return new OkObjectResult(recipient);
- }
-
- [HttpPut("mailrecipients")]
- public IActionResult UpdateRecipient([FromBody] MailRecipient rec)
- {
- _repo.UpdateMailRecipient(rec);
- return new OkResult();
- }
-
- [HttpDelete("mailrecipient/{id}")]
- public IActionResult DeleteRecipient(int id)
- {
- _repo.DeleteMailRecipient(id);
- return new OkResult();
- }
- }
- }
|