naprawiony mailsener
This commit is contained in:
parent
7ef186c12b
commit
3607ce2f2b
@ -7,20 +7,32 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace MailSender.Controllers
|
||||
{
|
||||
[RoutePrefix("")]
|
||||
public class HomeController : Controller
|
||||
{
|
||||
[HttpPost]
|
||||
public ActionResult Index([System.Web.Http.FromBody]MailDTO.MailDTO mail)
|
||||
{
|
||||
var model = new Models.MailModel(mail);
|
||||
return View(model);
|
||||
var model = new Models.MailModel(mail);
|
||||
TempData.Add("mailMod", model);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult Index()
|
||||
{
|
||||
if(TempData["mailMod"] != null)
|
||||
{
|
||||
return View(TempData["mailMod"]);
|
||||
}
|
||||
return View(new Models.MailModel());
|
||||
}
|
||||
|
||||
[System.Web.Http.HttpGet]
|
||||
public ActionResult Error(string errMsg)
|
||||
{
|
||||
ViewData.Add("errMsg", errMsg);
|
||||
return View();
|
||||
TempData.Add("errMsg", errMsg);
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
[System.Web.Mvc.HttpPost]
|
||||
|
@ -30,6 +30,10 @@ namespace MailSender.Models
|
||||
[StringLength(500, ErrorMessage = "Message has to have between 1 and 500 chars", MinimumLength = 1)]
|
||||
public string Content { get; set; }
|
||||
|
||||
public MailModel()
|
||||
{
|
||||
Content = EMailTo = Subject = string.Empty;
|
||||
}
|
||||
|
||||
public MailModel(MailDTO.MailDTO DTO)
|
||||
{
|
||||
|
@ -4,9 +4,11 @@
|
||||
}
|
||||
|
||||
|
||||
@if (ViewData.ContainsKey("mailErr"))
|
||||
@if (TempData["mailErr"] != null)
|
||||
{
|
||||
<h3>Error: @ViewData["mailErr"]</h3>
|
||||
string errStr = TempData["mailErr"] as string;
|
||||
<h3>Error: @TempData["mailErr"]</h3>
|
||||
TempData["mailErr"] = null;
|
||||
}
|
||||
|
||||
@using (Html.BeginForm("Send", "Home", FormMethod.Post))
|
||||
|
Loading…
Reference in New Issue
Block a user