troche chujowo ale dziala

This commit is contained in:
s440054 2018-12-18 15:42:39 +01:00
parent 57b54662ec
commit 66bad5435a
28 changed files with 60 additions and 116 deletions

View File

@ -1,8 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Forum.DataAccessLayer.Models namespace Forum.DataAccessLayer.Models
{ {

View File

@ -1,8 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Forum.DataAccessLayer.Models namespace Forum.DataAccessLayer.Models
{ {

View File

@ -1,11 +1,5 @@
using System; using System.Security.Claims;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
namespace Forum.DataAccessLayer.Models namespace Forum.DataAccessLayer.Models
{ {

View File

@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following

View File

@ -1,9 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Forum.DataAccessLayer.Models namespace Forum.DataAccessLayer.Models
{ {

View File

@ -1,11 +1,4 @@
using System; using Forum.DataAccessLayer.Models;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Forum.DataAccessLayer.Models;
using Microsoft.AspNet.Identity.EntityFramework;
namespace Forum.DataAccessLayer namespace Forum.DataAccessLayer
{ {

View File

@ -1,13 +1,6 @@
using System; using System.Security.Claims;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Forum.DataAccessLayer.Models; using Forum.DataAccessLayer.Models;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin;
using Microsoft.Owin.Security;
namespace Forum.DataAccessLayer.Managers namespace Forum.DataAccessLayer.Managers
{ {

View File

@ -1,14 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Forum.DataAccessLayer.Models; using Forum.DataAccessLayer.Models;
using Forum.DataAccessLayer.Services; using Forum.DataAccessLayer.Services;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin;
namespace Forum.DataAccessLayer.Managers namespace Forum.DataAccessLayer.Managers
{ {

View File

@ -1,7 +1,5 @@
namespace Forum.DataAccessLayer.Migrations namespace Forum.DataAccessLayer.Migrations
{ {
using System;
using System.Data.Entity.Migrations;
public partial class Dbinit : DbMigration public partial class Dbinit : DbMigration
{ {

View File

@ -1,7 +1,5 @@
namespace Forum.DataAccessLayer.Migrations namespace Forum.DataAccessLayer.Migrations
{ {
using System;
using System.Data.Entity.Migrations;
public partial class ConfigureDbTables : DbMigration public partial class ConfigureDbTables : DbMigration
{ {

View File

@ -1,7 +1,5 @@
namespace Forum.DataAccessLayer.Migrations namespace Forum.DataAccessLayer.Migrations
{ {
using System;
using System.Data.Entity.Migrations;
public partial class Emailvalidation : DbMigration public partial class Emailvalidation : DbMigration
{ {

View File

@ -1,7 +1,5 @@
namespace Forum.DataAccessLayer.Migrations namespace Forum.DataAccessLayer.Migrations
{ {
using System;
using System.Data.Entity.Migrations;
public partial class AddedTitle : DbMigration public partial class AddedTitle : DbMigration
{ {

View File

@ -1,7 +1,5 @@
namespace Forum.DataAccessLayer.Migrations namespace Forum.DataAccessLayer.Migrations
{ {
using System;
using System.Data.Entity.Migrations;
public partial class Seedtry : DbMigration public partial class Seedtry : DbMigration
{ {

View File

@ -4,8 +4,6 @@ using Forum.DataAccessLayer.Models;
namespace Forum.DataAccessLayer.Migrations namespace Forum.DataAccessLayer.Migrations
{ {
using System; using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq; using System.Linq;
internal sealed class Configuration : DbMigrationsConfiguration<Forum.DataAccessLayer.ApplicationDbContext> internal sealed class Configuration : DbMigrationsConfiguration<Forum.DataAccessLayer.ApplicationDbContext>

View File

@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following

View File

@ -1,9 +1,4 @@
using System; using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
namespace Forum.DataAccessLayer.Services namespace Forum.DataAccessLayer.Services
{ {

View File

@ -1,9 +1,4 @@
using System; using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
namespace Forum.DataAccessLayer.Services namespace Forum.DataAccessLayer.Services
{ {

View File

@ -1,5 +1,4 @@
using System.Web; using System.Web.Optimization;
using System.Web.Optimization;
namespace MailSender namespace MailSender
{ {

View File

@ -1,5 +1,4 @@
using System.Web; using System.Web.Mvc;
using System.Web.Mvc;
namespace MailSender namespace MailSender
{ {

View File

@ -1,8 +1,4 @@
using System; using System.Web.Mvc;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing; using System.Web.Routing;
namespace MailSender namespace MailSender

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Newtonsoft.Json;
namespace MailSender.Controllers
{
[RoutePrefix("def")]
public class DefaultController : Controller
{
[HttpGet]
public ActionResult Index()
{
var model = JsonConvert.SerializeObject(new Models.MailModel() { Content = "DDD", EMailTo = "ddd@o2.pl", Subject = "LLLLLL" });
TempData.Add("mailModel", model);
return RedirectToAction("Index", "Home");
}
}
}

View File

@ -1,12 +1,10 @@
using System; using System.Net.Mail;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Net; using System.Net;
using System.Web.Mvc; using System.Web.Mvc;
using System.Web.Helpers; using System.Net.Http;
using System.Threading.Tasks; using System.Web.ModelBinding;
using System;
using Newtonsoft.Json;
namespace MailSender.Controllers namespace MailSender.Controllers
{ {
@ -15,7 +13,13 @@ namespace MailSender.Controllers
[HttpGet] [HttpGet]
public ActionResult Index() public ActionResult Index()
{ {
return View(new Models.MailModel()); string jsonString = TempData["mailModel"] as string;
Models.MailModel model = null;
if (!String.IsNullOrEmpty(jsonString))
model = JsonConvert.DeserializeObject<Models.MailModel>(jsonString);
if (model == null)
model = new Models.MailModel();
return View(model);
} }
[HttpGet] [HttpGet]
@ -26,7 +30,7 @@ namespace MailSender.Controllers
} }
[HttpPost] [HttpPost]
public ActionResult Index(MailSender.Models.MailModel model) public ActionResult Send(MailSender.Models.MailModel model)
{ {
if (ModelState.IsValid) if (ModelState.IsValid)
{ {

View File

@ -1,8 +1,4 @@
using System; using System.Web.Mvc;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization; using System.Web.Optimization;
using System.Web.Routing; using System.Web.Routing;

View File

@ -159,6 +159,7 @@
<Compile Include="App_Start\BundleConfig.cs" /> <Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" /> <Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\RouteConfig.cs" /> <Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="Controllers\DefaultController.cs" />
<Compile Include="Controllers\HomeController.cs" /> <Compile Include="Controllers\HomeController.cs" />
<Compile Include="Global.asax.cs"> <Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon> <DependentUpon>Global.asax</DependentUpon>
@ -207,6 +208,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="App_Data\" /> <Folder Include="App_Data\" />
<Folder Include="Views\Default\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="fonts\glyphicons-halflings-regular.woff2" /> <Content Include="fonts\glyphicons-halflings-regular.woff2" />

View File

@ -1,9 +1,4 @@
using System; using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
namespace MailSender.Models namespace MailSender.Models
@ -33,5 +28,6 @@ namespace MailSender.Models
[DataType(DataType.MultilineText)] [DataType(DataType.MultilineText)]
[StringLength(500, ErrorMessage = "Message has to have between 1 and 500 chars", MinimumLength = 1)] [StringLength(500, ErrorMessage = "Message has to have between 1 and 500 chars", MinimumLength = 1)]
public string Content { get; set; } public string Content { get; set; }
} }
} }

View File

@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// Informacje ogólne o zestawie zależą od poniższego // Informacje ogólne o zestawie zależą od poniższego

View File

@ -1,9 +1,4 @@
using System; namespace MailSender
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MailSender
{ {
public class Settings public class Settings
{ {

View File

@ -9,27 +9,27 @@
<h3>Error: @ViewData["mailErr"]</h3> <h3>Error: @ViewData["mailErr"]</h3>
} }
@using (Html.BeginForm("Index", "Home", FormMethod.Post)) @using (Html.BeginForm("Send", "Home", FormMethod.Post))
{ {
<div class="form-group"> <div class="form-group">
@Html.LabelFor(i => i.Subject, new { @class = "label-form" }) @Html.LabelFor(i => i.Subject, new { @class = "label-form" })
@Html.EditorFor(i => i.Subject, new { htmlAttributes = new { @class = "form-control form-emailsend", @placeholder = "Temat" } }) @Html.EditorFor(i => i.Subject, new { htmlAttributes = new { @value = Model.Subject, @class = "form-control form-emailsend", @placeholder = "Temat" } })
@Html.ValidationMessageFor(i => i.Subject) @Html.ValidationMessageFor(i => i.Subject)
</div> </div>
<div class="form-group"> <div class="form-group">
@Html.LabelFor(i => i.EMailTo, new { @class = "label-form" }) @Html.LabelFor(i => i.EMailTo, new { @class = "label-form" })
@Html.EditorFor(i => i.EMailTo, new { htmlAttributes = new { @class = "form-control form-emailsend", @placeholder = "Do" } }) @Html.EditorFor(i => i.EMailTo, new { htmlAttributes = new { @value = Model.EMailTo, @class = "form-control form-emailsend", @placeholder = "Do" } })
@Html.ValidationMessageFor(i => i.EMailTo) @Html.ValidationMessageFor(i => i.EMailTo)
</div> </div>
<div class="form-group" > <div class="form-group" >
@Html.LabelFor(i => i.Content, new { @class = "label-form" }) @Html.LabelFor(i => i.Content, new { @class = "label-form" })
@Html.EditorFor(i => i.Content, new { htmlAttributes = new { @class = "form-control", @id = "exampleFormControlTextarea3", @rows=9, @placeholder = "Odpowiedź" } }) @Html.EditorFor(i => i.Content, new { htmlAttributes = new { @value = Model.Content, @class = "form-control", @id = "exampleFormControlTextarea3", @rows=9, @placeholder = "Odpowiedź" } })
@Html.ValidationMessageFor(i => i.Content) @Html.ValidationMessageFor(i => i.Content)
</div> </div>
<input type="submit" value="Send" class="answer-list__add-btn answer-list__add-btn--sendButton" /> <input type="submit" value="Wyślij" class="answer-list__add-btn answer-list__add-btn--sendButton" />
} }
@section Scripts { @section Scripts {