49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Options;
|
|
using OFBButte.Application.Configuration;
|
|
using OFBButte.Application.Database;
|
|
using OFBButte.Application.Email;
|
|
using OFBButte.Application.Missionary;
|
|
using OFBButte.Entities;
|
|
|
|
namespace OFBButte.Api.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class MissionaryController : ControllerBase
|
|
{
|
|
private readonly AppSettings appSettings;
|
|
private readonly IOFBContext context;
|
|
private readonly IEmailSender emailSender;
|
|
public MissionaryController(IOptions<AppSettings> options, IOFBContext context, IEmailSender emailSender)
|
|
{
|
|
this.appSettings = options.Value;
|
|
this.context = context;
|
|
this.emailSender = emailSender;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<ActionResult<MissionarySupport>> Post([FromBody] MissionarySupport value)
|
|
{
|
|
var adder = new AddAndSendMissionaryForm(context, emailSender);
|
|
var result = await adder.Handle(value, appSettings.MissionaryEmailAddress);
|
|
return result;
|
|
}
|
|
|
|
[HttpGet("{id}")]
|
|
public ActionResult<MissionarySupport> Get(int id)
|
|
{
|
|
throw new NotImplementedException();
|
|
var getter = new GetMissionarySupportForm(context);
|
|
var result = getter.Handle(id);
|
|
return result;
|
|
}
|
|
|
|
|
|
}
|
|
} |