using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using SkyArtShop.Models;
using SkyArtShop.Services;

namespace SkyArtShop.Controllers;

public class ContactController : Controller
{
	private readonly PostgreSQLService _pgService;

	public ContactController(PostgreSQLService pgService)
	{
		_pgService = pgService;
	}

	public async Task<IActionResult> Index()
	{
		SiteSettings model = (await _pgService.GetSiteSettingsAsync()) ?? new SiteSettings();
		return View(model);
	}

	[HttpPost]
	public IActionResult Submit(string name, string email, string phone, string subject, string message)
	{
		base.TempData["Success"] = "Thank you! Your message has been sent. We'll get back to you soon.";
		return RedirectToAction("Index");
	}
}
