| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using DutchTreat.Data;
- using DutchTreat.Services;
- using DutchTreat.ViewModels;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DutchTreat.Controllers
- {
- public class AppController : Controller
- {
- private readonly IMailService _mailService;
- private readonly IDutchRepository _repository;
- public AppController(IMailService mailService, IDutchRepository repository)
- {
- _mailService = mailService;
- _repository = repository;
- }
- public IActionResult Index()
- {
- var results = _repository.GetAllProducts();
- return View();
- }
- [HttpGet("Contact")]
- public IActionResult Contact()
- {
- return View();
- }
- [HttpPost("Contact")]
- public IActionResult Contact(ContactViewModel model)
- {
- if (ModelState.IsValid)
- {
- _mailService.SendMessage("", model.Subject, $"From: {model.Name} - {model.Email}, Message: {model.Message}");
- ViewBag.UserMessage = "Mail Sent";
- ModelState.Clear();
- }
- return View();
- }
- public IActionResult About()
- {
- ViewBag.Title = "About Us";
- return View();
- }
- public IActionResult Shop()
- {
- var results = _repository.GetAllProducts();
- return View(results);
- }
- }
- }
|