Compare commits

...

52 Commits

Author SHA1 Message Date
09ef1ca66e Niekompletna 2018-12-20 07:27:02 +00:00
20655b74f0 Dokumentacja z dodaną zmianą hasła 2018-12-20 06:34:34 +00:00
ff5163cea5 Delete 'instrukcja obsługi.pdf' 2018-12-20 06:34:10 +00:00
1ed563fc7c Dokumentacja z dodaną zmianą hasła 2018-12-20 06:33:41 +00:00
cd89c4bdf7 Delete 'Dokumentacja/instrukcja obsługi.pdf' 2018-12-20 06:33:00 +00:00
d98f7d101a Upload files to 'Dokumentacja' 2018-12-20 06:09:23 +00:00
81b497f02d Najnowsza architektura, poprawione błędy 2018-12-20 01:03:19 +00:00
95bae9565f Usuń 'Dokumentacja/Architektura najnowsza.pdf' 2018-12-20 01:02:55 +00:00
nlitkowski
007fe99f1b Merge branch 'master' of https://git.wmi.amu.edu.pl/s434799/Forum-Inzynieria1 2018-12-20 01:59:57 +01:00
nlitkowski
e9ed7d4b77 redirect do forum po mailu, bug fix, setings wywalone w kosmos 2018-12-20 01:59:38 +01:00
18038707d0 Poprawiona dokumentacja API 2018-12-20 00:29:52 +00:00
nlitkowski
3607ce2f2b naprawiony mailsener 2018-12-20 01:22:51 +01:00
7ef186c12b Plan forum z poprawionymi błędami 2018-12-20 00:09:30 +00:00
0e062a57e9 Najnowsza architektura, poprawione błędy 2018-12-19 23:53:58 +00:00
2cc1af2149 Usuń 'Dokumentacja/Poprawiona-architektura.docx' 2018-12-19 23:49:44 +00:00
c5ca2aa2dc Architektura najnowsza, poprawione błędy 2018-12-19 23:49:18 +00:00
5115b88e85 Prześlij pliki do 'Dokumentacja' 2018-12-19 22:36:45 +00:00
1a97cae65f Usuń 'Dokumentacja/Poprawiona architektura.pdf' 2018-12-19 22:35:59 +00:00
4f2e75eed1 Prześlij pliki do 'Dokumentacja' 2018-12-19 22:30:44 +00:00
cf4cc5650e Usuń 'Dokumentacja/Wstępna architektura systemu.pdf' 2018-12-19 22:28:51 +00:00
Bartosz Chyzy
a0c5d4357b Dodani usuwanie odpowiedzi 2018-12-19 23:26:12 +01:00
Bartosz Chyzy
d72384efe2 Norbert Litkowski nie umie w CSSa 2018-12-19 22:13:44 +01:00
Damian Lasecki
4240f1d563 Add style to edit and delete 2018-12-19 21:15:59 +01:00
Damian Lasecki
d9521ae99d Merge branch 'master' of https://git.wmi.amu.edu.pl/s434799/Forum-Inzynieria1 2018-12-19 21:13:11 +01:00
Damian Lasecki
fd836b41b5 Add style to edit and delete in category view 2018-12-19 21:12:04 +01:00
Bartosz Chyzy
88edf07e00 Zablokowano dostep do tworzenia kont przez randomow 2018-12-19 20:25:54 +01:00
Bartosz Chyzy
15830cf648 Pare spolszczen 2018-12-19 19:48:20 +01:00
Damian Lasecki
62eba388b4 Remove letter bug 2018-12-19 19:26:24 +01:00
Damian Lasecki
aa4ae61818 Styling manage category 2018-12-19 19:19:48 +01:00
Bartosz Chyzy
df046dc2a0 Merge branch 'master' of https://git.wmi.amu.edu.pl/s434799/Forum-Inzynieria1 2018-12-19 13:51:04 +01:00
Bartosz Chyzy
3fd3fc128c Podpiecie do mailSendera 2018-12-19 13:50:49 +01:00
3c243891d0 Upload files to 'Dokumentacja' 2018-12-19 12:12:12 +00:00
a6521a35ef Delete 'Dokumentacja/Poprawiona architektura.pdf' 2018-12-19 12:11:54 +00:00
851b633e31 poprawiony kontroler MailSender 2018-12-19 13:09:24 +01:00
Bartosz Chyzy
c79fed0334 Poprawiono namespacey 2018-12-19 12:55:35 +01:00
13086a7f60 added maildto 2018-12-19 12:32:14 +01:00
Adnovac
cd309a208e Merge branch 'master' of https://git.wmi.amu.edu.pl/s434799/Forum-Inzynieria1 2018-12-19 12:10:30 +01:00
Adnovac
4a8e98e21f merge mailsender 2018-12-19 12:10:05 +01:00
3cef1b6f15 Delete 'Dokumentacja/Diagramy_Klas_UML_ERD.docx' 2018-12-19 10:55:49 +00:00
1ac7861508 Poprawiona architektura 2018-12-18 14:29:02 +00:00
Bartosz Chyży
79eef508b5 Dodano oznaczenie opowiedzi jako profesionalista 2018-12-18 13:42:59 +01:00
Bartosz Chyży
c1a6d311e0 Dodano zapisywanie odpowiedzi jako profesionalista 2018-12-18 13:39:47 +01:00
Bartosz Chyży
70bdf02761 Dodano konntroler kategorii 2018-12-18 12:54:02 +01:00
Bartosz Chyzy
8e90b463ae Merge remote-tracking branch 'remotes/origin/Styling-home-views' 2018-12-06 22:58:14 +01:00
Damian Lasecki
38c20d09ec Wystylizowano widoki z /home 2018-12-06 22:31:18 +01:00
Damian Lasecki
c577b17923 Wystylizowano widoki w /Home 2018-12-06 22:27:25 +01:00
58f0566d1d Scenariusz testów 2018-12-06 15:54:25 +00:00
8dcc5b212c Notatka 2018-12-05 22:24:11 +00:00
98218a4d17 Architektura systemu 2018-12-05 22:07:15 +00:00
Adnovac
26b46b9119 Diagramy ERD 2018-12-05 13:10:39 +01:00
Adnovac
feb7c7b746 -zbedny txt 2018-12-05 12:09:56 +01:00
Adnovac
04e0f15629 +wstepna dokumentacja 2018-12-05 12:08:07 +01:00
57 changed files with 1183 additions and 571 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Dokumentacja/Notatka.pdf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,7 @@
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
namespace Forum.DataAccessLayer.Models
{

View File

@ -1,4 +1,6 @@
using Forum.DataAccessLayer.Models;
using System.Data.Entity;
using Forum.DataAccessLayer.Models;
using Microsoft.AspNet.Identity.EntityFramework;
namespace Forum.DataAccessLayer
{

View File

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

View File

@ -1,6 +1,10 @@
using System;
using Forum.DataAccessLayer.Models;
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
{

View File

@ -1,3 +1,5 @@
using System.Data.Entity.Migrations;
namespace Forum.DataAccessLayer.Migrations
{

View File

@ -1,3 +1,5 @@
using System.Data.Entity.Migrations;
namespace Forum.DataAccessLayer.Migrations
{

View File

@ -1,3 +1,5 @@
using System.Data.Entity.Migrations;
namespace Forum.DataAccessLayer.Migrations
{

View File

@ -1,3 +1,5 @@
using System.Data.Entity.Migrations;
namespace Forum.DataAccessLayer.Migrations
{

View File

@ -1,3 +1,5 @@
using System.Data.Entity.Migrations;
namespace Forum.DataAccessLayer.Migrations
{

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Data.Entity.Migrations;
using Forum.DataAccessLayer.Models;
namespace Forum.DataAccessLayer.Migrations

View File

@ -1,4 +1,5 @@
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
namespace Forum.DataAccessLayer.Services
{

View File

@ -1,4 +1,5 @@
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
namespace Forum.DataAccessLayer.Services
{

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.136
VisualStudioVersion = 15.0.26730.15
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Forum", "Forum\Forum.csproj", "{E3C0D1F3-C4CC-4D3D-9960-F20179C60269}"
EndProject
@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Forum.DataAccessLayer", "Fo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MailSender", "MailSender\MailSender.csproj", "{24F3A3E9-F8B9-43A5-A5AB-FA627683750C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MailDTO", "MailDTO\MailDTO.csproj", "{07B5BD11-726F-4506-9FD8-783880AAE0EF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -35,6 +37,10 @@ Global
{24F3A3E9-F8B9-43A5-A5AB-FA627683750C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{24F3A3E9-F8B9-43A5-A5AB-FA627683750C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{24F3A3E9-F8B9-43A5-A5AB-FA627683750C}.Release|Any CPU.Build.0 = Release|Any CPU
{07B5BD11-726F-4506-9FD8-783880AAE0EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{07B5BD11-726F-4506-9FD8-783880AAE0EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{07B5BD11-726F-4506-9FD8-783880AAE0EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{07B5BD11-726F-4506-9FD8-783880AAE0EF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,363 +1,386 @@
body {
padding-top: 15rem;
padding-bottom: 20px;
}
/* Set padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
}
/* Override the default bootstrap behavior where horizontal description lists
will truncate terms that are too long to fit in the left column
*/
.dl-horizontal dt {
white-space: normal;
}
/* Set width on the form input elements since they're 100% wide by default */
input,
select {
max-width: 280px;
}
.navbar {
background: linear-gradient(#47478f 15%,#4d4794);
height: auto;
}
.navbar a {
color: #fafafa;
}
h2 {
margin: 1rem 0;
}
.navbar-toggle .icon-bar {
background: #b7c5d8;
width: 28px;
}
.navbar-brand {
font-size: 2.5rem;
font-weight: 700;
height: 70px;
line-height: 4rem;
}
.navbar-toggle {
margin-top: 18px;
}
.navbar > .container {
width: 90%;
}
.nav > li > a:hover, .nav > li > a:focus {
background-color: #5a5aa7;
}
.category-list-wrapper {
width: 80%;
margin: 0 auto;
}
.category-wrapper > ul {
list-style: none;
}
.category-list {
display: grid;
padding: 0;
grid-row-gap: 2rem;
}
.category-list > li {
height: 9rem;
display: flex;
justify-content: center;
align-items: center;
background-color: #bbbbc5;
border-radius: 1rem;
position: relative;
}
.category-list > li > a {
text-decoration: none;
color: #fafafa;
font-size: 3rem;
display: block;
width: 100%;
height: 100%;
text-align: center;
line-height: 9rem;
overflow: hidden;
}
.single-category-wrapper {
padding: 3rem;
background-color: #f2f2f2;
border-radius: 1rem;
}
.single-category-wrapper > h2 {
margin: 1rem 0;
}
.single-category-wrapper > ul {
padding: 0;
list-style: none;
}
.single-category-wrapper > ul li {
padding: 1.5rem 0;
font-size: 1.5rem;
}
.single-category-wrapper > ul li a {
text-decoration: none;
color: #3b3b3b;
}
.add-topic {
width: 100%;
border: none;
background: #79bd9b;
padding: 10px;
border-radius: 1rem;
font-size: 1.8rem;
margin-top: 1rem;
}
.add-topic > a {
color: #fafafa;
text-decoration: none;
display: block;
width: 100%;
height: 100%;
}
.form-AddQuestion {
background-color: #f1f1f3;
padding: 3rem;
border-radius: 1rem;
}
.form-AddQuestion input {
max-width: none;
}
.form-personal-data {
display: flex;
flex-direction: column;
width: 100%;
justify-content: space-between;
}
.form-personal-data .form-group {
width: 100%;
}
.form-AddQuestion input[type=submit], .add-answer input[type=submit] {
border: none;
background: #79bd9b;
padding: 10px;
border-radius: 1rem;
font-size: 1.8rem;
color: #fafafa;
}
.form-AddQuestion input[type=submit] {
margin-top: 1.7rem;
}
.form-AddQuestion__btn {
width: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
}
.textarea-wrapper {
width: 50%;
margin: 20px auto;
padding: 5px; /*workaround for textarea margin*/
background: #FFF;
border: 1px solid #808080;
}
textarea {
max-width: none;
width: 100%;
}
.answer-list__question {
background: #dee0eb;
padding: 3rem;
overflow-wrap: break-word;
border-radius: 1rem;
margin-bottom: 5rem;
}
.answer-list__question h2 {
margin: 0;
width: 80%;
}
.answer-list__info {
display: flex;
justify-content: space-between;
align-items: center;
}
.answer-list__answer {
list-style: none;
padding: 0;
}
.username {
font-weight: 700;
}
.answer-list__answer__info {
background: #4d4c4c;
color: #fafafa;
padding: 1rem 2rem;
display: flex;
justify-content: space-between;
border-radius: 1rem;
}
.answer-list__answer__info--proffesional {
background: #c68585;
}
.answer-list__single-answer {
border: 1px solid #c0bebe;
border-radius: 1rem;
margin-bottom: 3rem;
border-top: none;
}
.answer-list__content {
padding: 2rem 2rem;
width: 100%;
overflow-wrap: break-word;
}
.answer-list__heading {
margin: 2rem 0;
}
.answer-list__add-btn {
border: none;
background: #79bd9b;
border-radius: 1rem;
font-size: 1.8rem;
color: #fafafa;
width: 20rem;
display: flex;
justify-content: center;
align-items: center;
height: 5rem;
}
.answer-list__add-btn a {
text-decoration: none;
display: block;
width: 100%;
height: 100%;
color: white;
text-align: center;
line-height: 5rem;
}
.add-answer {
background: #f2f2f2;
padding: 3rem;
border-radius: 1rem;
}
@media (min-width: 768px) {
.navbar > .container {
height: 10rem;
}
.navbar-header {
height: 100%;
display: flex;
align-items: center;
}
.navbar-brand {
font-size: 3.5rem;
}
.navbar-nav {
height: 100px;
display: flex;
align-items: center;
}
.navbar-nav > li {
height: 50%;
}
.navbar-nav > li > a {
height: 100%;
border-radius: 0.8rem;
}
.nav > li > a:hover, .nav > li > a:focus {
transition: background-color .1s ease;
}
.category-list {
/*grid-template-columns: 1fr 1fr;*/
grid-column-gap: 2rem;
}
.single-category-wrapper {
width: 65%;
margin: 0 auto;
}
.form-AddQuestion__btn {
flex-direction: row;
margin-top: 1rem;
}
.form-personal-data {
flex-direction: row;
}
.form-personal-data .form-group {
width: 49%;
}
.form-AddQuestion input[type=submit] {
margin-top: 0;
}
}
body {
padding-top: 15rem;
padding-bottom: 20px;
}
/* Set padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
}
/* Override the default bootstrap behavior where horizontal description lists
will truncate terms that are too long to fit in the left column
*/
.dl-horizontal dt {
white-space: normal;
}
/* Set width on the form input elements since they're 100% wide by default */
input,
select
{
max-width: 280px;
}
.navbar {
background: linear-gradient(#47478f 15%,#4d4794);
height: auto;
}
.navbar a {
color: #fafafa;
}
h2{
margin: 1rem 0;
}
.navbar-toggle .icon-bar {
background: #b7c5d8;
width: 28px;
}
.navbar-brand{
font-size:2.5rem;
font-weight:700;
height:70px;
line-height:4rem;
}
.navbar-toggle{
margin-top:18px;
}
.navbar > .container {
width: 90%;
}
.nav > li > a:hover, .nav > li > a:focus{
background-color:#5a5aa7 ;
}
.category-list-wrapper{
width:80%;
margin:0 auto;
}
.category-wrapper > ul {
list-style: none;
}
.category-list{
display: grid;
padding:0;
grid-row-gap: 2rem;
}
.category-list > li {
height: 9rem;
display: flex;
justify-content: center;
align-items: center;
background-color:#bbbbc5;
border-radius: 1rem;
position:relative;
}
.category-list > li > a {
text-decoration: none;
color: #fafafa;
font-size: 3rem;
display: block;
width: 100%;
height: 100%;
text-align: center;
line-height: 9rem;
overflow: hidden;
}
.single-category-wrapper{
padding: 3rem;
background-color: #f2f2f2;
border-radius: 1rem;
}
.single-category-wrapper > h2 {
margin:1rem 0;
}
.single-category-wrapper > ul {
padding:0;
list-style: none;
}
.single-category-wrapper > ul li {
padding: 1.5rem 0;
font-size:1.5rem;
}
.single-category-wrapper > ul li a {
text-decoration: none;
color: #3b3b3b;
}
.add-topic {
width: 100%;
border: none;
background: #79bd9b;
padding: 10px;
border-radius: 1rem;
font-size: 1.8rem;
margin-top: 1rem;
}
.add-topic > a{
color: #fafafa;
text-decoration: none;
display:block;
width:100%;
height:100%;
}
.form-AddQuestion {
background-color: #f1f1f3;
padding: 3rem;
border-radius: 1rem;
}
.form-AddQuestion input {
max-width: none;
}
.form-personal-data{
display: flex;
flex-direction: column;
width:100%;
justify-content: space-between;
}
.form-personal-data .form-group {
width:100%;
}
.form-AddQuestion input[type=submit], .add-answer input[type=submit] {
border: none;
background: #79bd9b;
padding: 10px;
border-radius: 1rem;
font-size: 1.8rem;
color: #fafafa;
}
.form-AddQuestion input[type=submit]{
margin-top: 1.7rem;
}
.form-AddQuestion__btn{
width:100%;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
}
.textarea-wrapper {
width: 50%;
margin: 20px auto;
padding: 5px; /*workaround for textarea margin*/
background: #FFF;
border: 1px solid #808080;
}
textarea {
max-width: none;
width: 100%;
}
.answer-list__question {
background: #dee0eb;
padding: 3rem;
overflow-wrap: break-word;
border-radius: 1rem;
margin-bottom: 5rem;
}
.answer-list__question h2 {
margin:0;
width: 80%;
}
.answer-list__info {
display: flex;
justify-content: space-between;
align-items:center;
}
.answer-list__answer {
list-style: none;
padding:0;
}
.username {
font-weight: 700;
}
.answer-list__answer__info {
background: #4d4c4c;
color: #fafafa;
padding: 1rem 2rem;
display: flex;
justify-content: space-between;
border-radius: 1rem;
}
.answer-list__answer__info--proffesional {
background: #c68585;
}
.answer-list__single-answer {
border: 1px solid #c0bebe;
border-radius: 1rem;
margin-bottom: 3rem;
border-top: none;
}
.answer-list__content {
padding: 2rem 2rem;
width: 100%;
overflow-wrap: break-word;
}
.answer-list__heading {
margin: 2rem 0;
}
.answer-list__add-btn {
border: none;
background: #79bd9b;
border-radius: 1rem;
font-size: 1.8rem;
color: #fafafa;
width: 20rem;
display: flex;
justify-content:center;
align-items:center;
height: 5rem;
}
.answer-list__add-btn a {
text-decoration: none;
display: block;
width: 100%;
height: 100%;
color: white;
text-align: center;
line-height: 5rem;
}
.add-answer {
background: #f2f2f2;
padding: 3rem;
border-radius: 1rem;
}
.wrapper {
padding: 3rem;
background-color: #f2f2f2;
}
.delete-category__span{
font-size:2rem;
font-weight:400;
margin-bottom:10rem;
}
.delete-category__dl {
height: 3rem;
margin-bottom: 3rem;
}
@media (min-width: 768px) {
.navbar > .container {
height: 10rem;
}
.navbar-header {
height: 100%;
display: flex;
align-items: center;
}
.navbar-brand {
font-size: 3.5rem;
}
.navbar-nav {
height: 100px;
display: flex;
align-items: center;
}
.navbar-nav > li {
height: 50%;
}
.navbar-nav > li > a {
height: 100%;
border-radius: 0.8rem;
}
.nav > li > a:hover, .nav > li > a:focus {
transition: background-color .1s ease;
}
.category-list {
grid-template-columns: 1fr 1fr;
grid-column-gap: 2rem;
}
.single-category-wrapper {
width: 65%;
margin: 0 auto;
}
.form-AddQuestion__btn {
flex-direction: row;
margin-top: 1rem;
}
.form-personal-data {
flex-direction: row;
}
.form-personal-data .form-group {
width: 49%;
}
.form-AddQuestion input[type=submit] {
margin-top: 0;
}
}

View File

@ -20,9 +20,7 @@ namespace Forum.Controllers
private ApplicationSignInManager _signInManager;
private ApplicationUserManager _userManager;
public AccountController()
{
}
public AccountController(){}
public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager )
{
@ -88,7 +86,7 @@ namespace Forum.Controllers
return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
case SignInStatus.Failure:
default:
ModelState.AddModelError("", "Invalid login attempt.");
ModelState.AddModelError("", "Niepoprawny login lub hasło");
return View(model);
}
}
@ -138,7 +136,7 @@ namespace Forum.Controllers
//
// GET: /Account/Register
[AllowAnonymous]
[Authorize]
public ActionResult Register()
{
return View();
@ -147,13 +145,13 @@ namespace Forum.Controllers
//
// POST: /Account/Register
[HttpPost]
[AllowAnonymous]
[Authorize]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
var user = new ProfessionalUser() { UserName = model.Email, Email = model.Email };
var user = new ProfessionalUser() { UserName = model.Email, Email = model.Email,FullName = model.FullName};
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{

View File

@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using Forum.DataAccessLayer;
using Forum.DataAccessLayer.Models;
namespace Forum.Controllers
{
[Authorize]
public class CategoriesController : Controller
{
private ApplicationDbContext db = new ApplicationDbContext();
// GET: Categories
public ActionResult Index()
{
return View(db.Categories.ToList());
}
// GET: Categories/Create
public ActionResult Create()
{
return View();
}
// POST: Categories/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "Id,CategoryName")] Category category)
{
if (ModelState.IsValid)
{
db.Categories.Add(category);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(category);
}
// GET: Categories/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Category category = db.Categories.Find(id);
if (category == null)
{
return HttpNotFound();
}
return View(category);
}
// POST: Categories/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see https://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "Id,CategoryName")] Category category)
{
if (ModelState.IsValid)
{
db.Entry(category).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(category);
}
// GET: Categories/Delete/5
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Category category = db.Categories.Find(id);
if (category == null)
{
return HttpNotFound();
}
return View(category);
}
// POST: Categories/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Category category = db.Categories.Find(id);
db.Categories.Remove(category);
db.SaveChanges();
return RedirectToAction("Index");
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
db.Dispose();
}
base.Dispose(disposing);
}
}
}

View File

@ -1,11 +1,16 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.Entity;
using System.Linq;
using System.Security.Principal;
using System.Threading.Tasks;
using System.Web.Mvc;
using Fluentx.Mvc;
using Forum.DataAccessLayer;
using Forum.DataAccessLayer.Models;
using Forum.ViewModels;
using Microsoft.AspNet.Identity;
namespace Forum.Controllers
{
@ -99,19 +104,54 @@ namespace Forum.Controllers
if (question == null)
return HttpNotFound();
var user = _dbContext.Users.Find(User.Identity.GetUserId());
var answer = new Answer()
{
Content = model.Content,
Nick = model.Nick,
Date = DateTime.Now
Date = DateTime.Now,
Professional = user
};
question.Answers.Add(answer);
_dbContext.SaveChanges();
//Logika wysylania maili
if (User.Identity.IsAuthenticated && !string.IsNullOrEmpty(question.ReportersEmail))
{
var dataToPost = new Dictionary<string, object>();
dataToPost.Add("Subject",question.Title);
dataToPost.Add("EMailTo",question.ReportersEmail);
dataToPost.Add("Content",model.Content);
return this.RedirectAndPost(ConfigurationManager.AppSettings["MailSenderAddress"], dataToPost);
}
return RedirectToAction("Question", new {id = model.QuestionId});
}
[Authorize]
[System.Web.Mvc.Route("Home/DeleteAnswer/{id}")]
public ActionResult DeleteAnswer(int? id)
{
var answer = _dbContext.Answers.Find(id);
var question = _dbContext.Questions.FirstOrDefault(x => x.Answers.Any(y => y.Id == id));
if (answer != null)
{
_dbContext.Answers.Remove(answer);
_dbContext.SaveChanges();
}
if (question != null)
return RedirectToAction("Question", new {id = question.Id});
return HttpNotFound();
}
}
}

View File

@ -47,6 +47,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Fluentx, Version=2.0.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Fluentx.2.0.4\lib\Fluentx.dll</HintPath>
</Reference>
<Reference Include="Fluentx.Mvc, Version=1.0.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Fluentx.Mvc.1.0.4\lib\Fluentx.Mvc.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNet.TelemetryCorrelation, Version=1.0.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.TelemetryCorrelation.1.0.4\lib\net45\Microsoft.AspNet.TelemetryCorrelation.dll</HintPath>
</Reference>
@ -176,6 +182,7 @@
<Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="App_Start\Startup.Auth.cs" />
<Compile Include="Controllers\AccountController.cs" />
<Compile Include="Controllers\CategoriesController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\ManageController.cs" />
<Compile Include="Global.asax.cs">
@ -215,6 +222,8 @@
<Content Include="Content\bootstrap.css.map" />
<Content Include="Content\bootstrap-theme.min.css.map" />
<Content Include="Content\bootstrap-theme.css.map" />
<None Include="Properties\PublishProfiles\forum-inzynieria1 - FTP.pubxml" />
<None Include="Properties\PublishProfiles\forum-inzynieria1 - Web Deploy.pubxml" />
<None Include="Scripts\jquery-3.3.1.intellisense.js" />
<Content Include="Scripts\jquery-3.3.1.js" />
<Content Include="Scripts\jquery-3.3.1.min.js" />
@ -281,9 +290,14 @@
<Content Include="Scripts\popper-utils.js.map" />
<Content Include="Views\Home\AddQuestion.cshtml" />
<Content Include="Views\Home\AddAnswer.cshtml" />
<Content Include="Views\Categories\Create.cshtml" />
<Content Include="Views\Categories\Delete.cshtml" />
<Content Include="Views\Categories\Edit.cshtml" />
<Content Include="Views\Categories\Index.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
<Folder Include="Views\Professional\" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

View File

@ -55,10 +55,10 @@ namespace Forum.Models
[Required]
[DataType(DataType.Password)]
[Display(Name = "Password")]
[Display(Name = "Hasło")]
public string Password { get; set; }
[Display(Name = "Remember me?")]
[Display(Name = "Zapamiętaj mnie")]
public bool RememberMe { get; set; }
}
@ -72,13 +72,17 @@ namespace Forum.Models
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
[Display(Name = "Hasło")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Display(Name = "Potwierdź hasło")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
[Display(Name = "Imię i nazwisko")]
[Required]
public string FullName { get; set; }
}
public class ResetPasswordViewModel

View File

@ -1,7 +1,7 @@
@using Forum.Models
@model LoginViewModel
@{
ViewBag.Title = "Log in";
ViewBag.Title = "Zaloguj się";
}
<h2>@ViewBag.Title.</h2>
@ -11,7 +11,6 @@
@using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<h4>Use a local account to log in.</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@ -38,11 +37,11 @@
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Log in" class="btn btn-default" />
<input type="submit" value="Zaloguj się" class="btn btn-default" />
</div>
</div>
<p>
@Html.ActionLink("Register as a new user", "Register")
@*@Html.ActionLink("Utwórz nowego użytkownika", "Register")*@
</p>
@* Enable this once you have account confirmation enabled for password reset functionality
<p>
@ -51,11 +50,7 @@
}
</section>
</div>
<div class="col-md-4">
<section id="socialLoginForm">
@Html.Partial("_ExternalLoginsListPartial", new ExternalLoginListViewModel { ReturnUrl = ViewBag.ReturnUrl })
</section>
</div>
</div>
@section Scripts {

View File

@ -1,6 +1,6 @@
@model Forum.Models.RegisterViewModel
@{
ViewBag.Title = "Register";
ViewBag.Title = "Zarejestruj się";
}
<h2>@ViewBag.Title.</h2>
@ -8,7 +8,6 @@
@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<h4>Create a new account.</h4>
<hr />
@Html.ValidationSummary("", new { @class = "text-danger" })
<div class="form-group">
@ -17,6 +16,12 @@
@Html.TextBoxFor(m => m.Email, new { @class = "form-control" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.FullName, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.FullName, new { @class = "form-control" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@ -31,7 +36,7 @@
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" class="btn btn-default" value="Register" />
<input type="submit" class="btn btn-default" value="Zarejestruj" />
</div>
</div>
}

View File

@ -0,0 +1,44 @@
@model Forum.DataAccessLayer.Models.Category
@{
ViewBag.Title = "Create";
}
<div class="single-category-wrapper">
<h2>Utwórz kategorie</h2>
<hr style="border-top: 1px solid #d3d3d3; margin-bottom: 3rem;" />
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.CategoryName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.CategoryName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.CategoryName, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Utwórz kategorie" class="answer-list__add-btn" style="height:4rem; width:17rem" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Powrót", "Index")
</div>
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

View File

@ -0,0 +1,34 @@
@model Forum.DataAccessLayer.Models.Category
@{
ViewBag.Title = "Delete";
}
<div class="single-category-wrapper">
<h2>Usuwanie ketegorii</h2>
<hr style="border-top: 1px solid #d3d3d3;" />
<span class="delete-category__span">Jesteś pewien, że chcesz usunąć kategorię?</span>
<div style="margin-top: 3rem;">
<dl class="dl-horizontal delete-category__dl">
<dt style="text-align:left">
@Html.DisplayNameFor(model => model.CategoryName)
</dt>
<dd style="margin-left:0;">
@Html.DisplayFor(model => model.CategoryName)
</dd>
</dl>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-actions no-color">
<input type="submit" value="Usuń" class="answer-list__add-btn" style="height:4rem; width:17rem; background-color:#af4f4f; margin-bottom: 3rem;" />
</div>
<div>@Html.ActionLink("Powrót do listy kategorii", "Index")
</div>
}
</div>
</div>

View File

@ -0,0 +1,42 @@
@model Forum.DataAccessLayer.Models.Category
@{
ViewBag.Title = "Edit";
}
<div class="single-category-wrapper">
<h2>Edytuj nazwię kategorii</h2>
<hr style="border-top: 1px solid #d3d3d3; margin-bottom: 3rem;" />
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.Id)
<div class="form-group">
@Html.LabelFor(model => model.CategoryName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.CategoryName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.CategoryName, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Zapisz" class="answer-list__add-btn" style="height:4rem; width:17rem" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Powrót do listy kategorii", "Index")
</div>
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

View File

@ -0,0 +1,35 @@
@model IEnumerable<Forum.DataAccessLayer.Models.Category>
@{
ViewBag.Title = "Index";
}
<div class="single-category-wrapper">
<h2 style="margin-bottom:3rem;">Kategorie</h2>
<table class="table">
<tr>
<th>
Nazwa kategorii
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.CategoryName)
</td>
<td>
@Html.ActionLink("Edytuj", "Edit", new { id = item.Id }) |
@Html.ActionLink("Usuń", "Delete", new { id = item.Id })
</td>
</tr>
}
</table>
<p class="answer-list__add-btn">
@Html.ActionLink("Utwórz kategorie", "Create")
</p>
</div>

View File

@ -1,26 +1,45 @@
@model Forum.ViewModels.AddAnswerViewModel
@{
ViewBag.Title = "AddAnswer";
}
<h2>AddAnswer</h2>
@using (Html.BeginForm("AddAnswer", "Home", FormMethod.Post))
{
<div class="form-group">
@Html.LabelFor(model => model.Nick, new { @class = "label-form" })
@Html.EditorFor(model => model.Nick, new { htmlAttributes = new { @class = "form-control" } })
</div>
<div class="form-group">
@Html.LabelFor(model => model.Content, new { @class = "label-form" })
@Html.EditorFor(model => model.Content, new { htmlAttributes = new { @class = "form-control" } })
</div>
@Html.HiddenFor(model=>model.QuestionId)
<input type="submit" value="Zgłoś" />
}
@model Forum.ViewModels.AddAnswerViewModel
@{
ViewBag.Title = "AddAnswer";
}
<div class="add-answer">
<h2>Dodaj odpowiedź</h2>
<hr style="border-top: 1px solid #d3d3d3; margin-bottom: 3rem;" />
@using (Html.BeginForm("AddAnswer", "Home", FormMethod.Post))
{
<div class="form-group">
@{
if (User.Identity.IsAuthenticated)
{
<label>Odpowiedz jako @User.Identity.Name</label>
}
else
{
@Html.EditorFor(model => model.Nick, new { htmlAttributes = new { @class = "form-control", placeholder = "Nick" } })
}
}
</div>
<div class="form-group">
@Html.TextAreaFor(model => model.Content, new { @class = "form-control", @id = "exampleFormControlTextarea3", rows = 7, placeholder = "Odpowiedź" })<br />
</div>
@Html.HiddenFor(model=>model.QuestionId)
<input type="submit" value="Zgłoś odpowiedź" />
}
</div>

View File

@ -1,38 +1,49 @@
@model Forum.ViewModels.AddQuestionViewModel
@{
ViewBag.Title = "AddQuestion";
}
<h2>AddQuestion</h2>
@using (Html.BeginForm("AddQuestion", "Home", FormMethod.Post))
{
<div class="form-group">
@Html.LabelFor(model => model.Title, new { @class = "label-form" })
@Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control" } })
</div>
<div class="form-group">
@Html.LabelFor(model => model.Content, new { @class = "label-form" })
@Html.EditorFor(model => model.Content, new { htmlAttributes = new { @class = "form-control" } })
</div>
<div class="form-group">
@Html.LabelFor(model => model.Nick, new { @class = "label-form" })
@Html.EditorFor(model => model.Nick, new { htmlAttributes = new { @class = "form-control" } })
</div>
<div class="form-group">
@Html.LabelFor(model => model.Email, new { @class = "label-form" })
@Html.EditorFor(model => model.Email, new { htmlAttributes = new { @class = "form-control" } })
</div>
@Html.DropDownListFor(x=>x.CategoryId,new SelectList(Model.Categories,"Id", "CategoryName"))
<input type="submit" value="Zgłoś"/>
}
@model Forum.ViewModels.AddQuestionViewModel
@{
ViewBag.Title = "AddQuestion";
}
@using (Html.BeginForm("AddQuestion", "Home", FormMethod.Post))
{
<div class="form-AddQuestion">
<h2>Dodaj zapytanie</h2>
<hr style="border-top: 1px solid #d3d3d3; margin-bottom:3rem;" />
<div class="form-group">
@Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control", placeholder="Temat" } })
</div>
<div class="form-group">
@Html.TextAreaFor(model => model.Content, new { @class="form-control", @id = "exampleFormControlTextarea3", rows=7, placeholder="Treść zapytania" })<br />
</div>
<div class="form-personal-data">
<div class="form-group">
@Html.EditorFor(model => model.Nick, new { htmlAttributes = new { @class = "form-control", placeholder="Nick" } })
</div>
<div class="form-group">
@Html.EditorFor(model => model.Email, new { htmlAttributes = new { @class = "form-control", placeholder="Adres email" } })
</div>
</div>
<div class="form-AddQuestion__btn">
@Html.DropDownListFor(x=>x.CategoryId,new SelectList(Model.Categories,"Id", "CategoryName"), new { @class = "form-control" })
<input type="submit" value="Dodaj zapytanie"/>
</div>
</div>
}

View File

@ -1,18 +1,36 @@
@model Forum.DataAccessLayer.Models.Category
@{
ViewBag.Title = Model.CategoryName;
}
<h2>@Model.CategoryName</h2>
@Html.ActionLink("Dodaj pytanie", "AddQuestion", "Home",new {category=Model.CategoryName},null)
<ul>
@{
foreach (var question in Model.Questions)
{
<li>@Html.ActionLink(question.Title,"Question","Home",new{id=question.Id},null)</li>
}
}
</ul>
@model Forum.DataAccessLayer.Models.Category
@{
ViewBag.Title = Model.CategoryName;
}
<div class="single-category-wrapper">
<h2>@Model.CategoryName</h2>
<hr style="border-top: 1px solid #d3d3d3" />
<ul class="single-category__topic">
@{
foreach (var question in Model.Questions)
{
string title = question.Title;
if (String.IsNullOrEmpty(title))
{
title = "Brak tytułu pytania";
}
<li>@Html.ActionLink(title, "Question", "Home", new { id = question.Id }, null)</li>
}
}
</ul>
<button class="add-topic">
@Html.ActionLink("Dodaj zapytanie", "AddQuestion", "Home", new { category = Model.CategoryName }, null)
</button>
</div>

View File

@ -1,18 +1,19 @@
@model IEnumerable<Forum.DataAccessLayer.Models.Category>
@{
ViewBag.Title = "Strona Główna";
}
<ul>
@{
foreach (var category in Model)
{
<li>
@Html.ActionLink(category.CategoryName,"Category","Home",new{name=category.CategoryName},null)
</li>
}
}
</ul>
@model IEnumerable<Forum.DataAccessLayer.Models.Category>
@{
ViewBag.Title = "Strona Główna";
}
<div class="category-list-wrapper">
<ul class="category-list">
@{
foreach (var category in Model)
{
<li>
@Html.ActionLink(category.CategoryName, "Category", "Home", new { name = category.CategoryName }, null)
</li>
}
}
</ul>
</div>

View File

@ -1,28 +1,65 @@
@model Forum.DataAccessLayer.Models.Question
@{
ViewBag.Title = @Model.Title;
}
@Model.PostDate
<h2>@Model.Title</h2>
<div>
@Model.Content
</div>
<hr/>
@Html.ActionLink("Dodaj odpowiedź","AddAnswer",new{id=@Model.Id})
<hr/>
<b>Odpowiedzi</b>
<ul>
@{
foreach (var answer in Model.Answers)
{
<li>@answer.Nick @answer.Date @answer.Content </li>
}
}
</ul>
@using WebGrease.Css.Extensions
@model Forum.DataAccessLayer.Models.Question
@{
ViewBag.Title = @Model.Title;
}
<div class="answer-list__question">
<div class="answer-list__info">
<h2>@Model.Title</h2>
@Model.PostDate
</div>
<hr style="border-top: 1px solid #d3d3d3" />
<div class="answer-list__question__content">
@Model.Content
</div>
</div>
<h3 class="answer-list__heading">Odpowiedzi</h3>
<ul class="answer-list__answer">
@{
foreach (var answer in Model.Answers)
{
<li class="answer-list__single-answer">
<div class="answer-list__answer__info" @{if (answer.Professional != null) { <text> style="background-color: #7ecc2a" </text> }}>
@{
if (answer.Professional != null)
{
<span class="username">@answer.Professional.FullName napisał(a)</span>
}
else
{
<span class="username">@answer.Nick napisał(a)</span>
}
}
@{
if (User.Identity.IsAuthenticated)
{
@Html.ActionLink("Usuń odpowiedź", "DeleteAnswer", new {id = answer.Id},new{@style="color:#fff;"});
}
}
@answer.Date
</div>
<div class="answer-list__content">
@answer.Content
</div>
</li>
}
}
</ul>
<div class="answer-list__add-btn">
@Html.ActionLink("Dodaj odpowiedź", "AddAnswer", new { id = @Model.Id })
</div>

View File

@ -9,7 +9,7 @@
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
@ -17,13 +17,14 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
@Html.ActionLink("FORUM", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
<ul class="nav navbar-nav">
@if (User.Identity.IsAuthenticated)
{
<li>@Html.ActionLink("Zarządzaj kategoriami", "Index", "Categories")</li>
}
</ul>
@Html.Partial("_LoginPartial")
</div>
@ -33,7 +34,7 @@
@RenderBody()
<hr />
<footer>
<p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>
<p>&copy; @DateTime.Now.Year - Grupa 1CF Inżynieria oprogramowania</p>
</footer>
</div>

View File

@ -7,16 +7,16 @@
<ul class="nav navbar-nav navbar-right">
<li>
@Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
@Html.ActionLink("Witaj " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
</li>
<li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
<li>@Html.ActionLink("Dodaj profesjonalistę", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
<li><a href="javascript:document.getElementById('logoutForm').submit()">Wyloguj się</a></li>
</ul>
}
}
else
{
<ul class="nav navbar-nav navbar-right">
<li>@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
<li>@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })</li>
<ul class="nav navbar-nav navbar-right">
<li>@Html.ActionLink("Zaloguj się", "Login", "Account", routeValues: null, htmlAttributes: new {id = "loginLink"})</li>
</ul>
}

View File

@ -12,6 +12,7 @@
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\ForumInzyneria1.mdf;Initial Catalog=ForumInzyneria1;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="MailSenderAddress" value="http://mailsender-inzynieria1.azurewebsites.net/Home/Index" />
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
@ -86,7 +87,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

View File

@ -3,6 +3,8 @@
<package id="Antlr" version="3.5.0.2" targetFramework="net461" />
<package id="bootstrap" version="3.3.7" targetFramework="net461" />
<package id="EntityFramework" version="6.2.0" targetFramework="net461" />
<package id="Fluentx" version="2.0.4" targetFramework="net461" />
<package id="Fluentx.Mvc" version="1.0.4" targetFramework="net461" />
<package id="jQuery" version="3.3.1" targetFramework="net461" />
<package id="jQuery.Validation" version="1.17.0" targetFramework="net461" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.2" targetFramework="net461" />

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MailDTO
{
public class MailDTO
{
public string Subject { get; set; }
public string EMailTo { get; set; }
public string Content { get; set; }
}
}

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{07B5BD11-726F-4506-9FD8-783880AAE0EF}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MailDTO</RootNamespace>
<AssemblyName>MailDTO</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MailDTO.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MailDTO")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MailDTO")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("07b5bd11-726f-4506-9fd8-783880aae0ef")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -301,6 +301,11 @@ textarea {
height: 200px;
}
.w100 {
width: 100% !important;
max-width: 100% !important;
}
.form-emailsend
{
color: black;

View File

@ -13,8 +13,8 @@ namespace MailSender.Controllers
[HttpGet]
public ActionResult Index()
{
var model = JsonConvert.SerializeObject(new Models.MailModel() { Content = "DDD", EMailTo = "ddd@o2.pl", Subject = "LLLLLL" });
TempData.Add("mailModel", model);
//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,49 +1,59 @@
using System.Net.Mail;
using System.Net;
using System.Web.Mvc;
using System.Net.Http;
using System.Web.ModelBinding;
using System;
using Newtonsoft.Json;
using System.Configuration;
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);
TempData.Add("mailMod", model);
return View(model);
}
[HttpGet]
public ActionResult Index()
{
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);
if(TempData["mailMod"] != null)
{
return View(TempData["mailMod"]);
}
return View(new Models.MailModel());
}
[HttpGet]
[System.Web.Http.HttpGet]
public ActionResult Error(string errMsg)
{
ViewData.Add("errMsg", errMsg);
return View();
TempData.Add("errMsg", errMsg);
return RedirectToAction("Index");
}
[HttpPost]
[System.Web.Mvc.HttpPost]
public ActionResult Send(MailSender.Models.MailModel model)
{
if (ModelState.IsValid)
{
var smtpClient = new SmtpClient(Settings.smtpServer, Settings.smtpPort)
var smtpClient = new SmtpClient(ConfigurationManager.AppSettings["smtp-server"],
Int32.Parse(ConfigurationManager.AppSettings["smtp-port"]))
{
Credentials = new NetworkCredential(Settings.user, Settings.pass),
Credentials = new NetworkCredential(
ConfigurationManager.AppSettings["user-mail"],
ConfigurationManager.AppSettings["pass-mail"]),
EnableSsl = true
};
smtpClient.Send(Settings.user, model.EMailTo, model.Subject, model.Content);
return RedirectToAction("Index");
smtpClient.Send(ConfigurationManager.AppSettings["user-mail"], model.EMailTo, model.Subject, model.Content);
return Redirect(ConfigurationManager.AppSettings["forum-address"]);
}
else
return RedirectToAction("Error", new { errMsg = "Error nie umiesz pisac maila menelu" });
return RedirectToAction("Error", new { errMsg = "Błąd wysyłania wiadomości e-mail." });
}
}
}

View File

@ -64,12 +64,21 @@
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
</Reference>
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
</Reference>
<Reference Include="System.Web.Http.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Web.Http.Common.4.0.20126.16343\lib\net40\System.Web.Http.Common.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
@ -166,7 +175,6 @@
</Compile>
<Compile Include="Models\MailModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Content\bootstrap-theme.css" />
@ -182,6 +190,8 @@
<Content Include="ApplicationInsights.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Properties\PublishProfiles\mailsender-inzynieria1 - FTP.pubxml" />
<None Include="Properties\PublishProfiles\mailsender-inzynieria1 - Web Deploy.pubxml" />
<None Include="Scripts\jquery-3.3.1.intellisense.js" />
<Content Include="Scripts\jquery-3.3.1.js" />
<Content Include="Scripts\jquery-3.3.1.min.js" />
@ -223,6 +233,12 @@
<Content Include="Scripts\jquery-3.3.1.slim.min.map" />
<Content Include="Scripts\jquery-3.3.1.min.map" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MailDTO\MailDTO.csproj">
<Project>{07b5bd11-726f-4506-9fd8-783880aae0ef}</Project>
<Name>MailDTO</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

View File

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using MailDTO;
using System.ComponentModel.DataAnnotations.Schema;
namespace MailSender.Models
@ -17,7 +18,7 @@ namespace MailSender.Models
public string Subject { get; set; }
[DataType(DataType.EmailAddress)]
[Required(AllowEmptyStrings = false, ErrorMessage = "Musisz wprowadzić adres e-mail")]
[Required(AllowEmptyStrings = false, ErrorMessage = "Musisz wprowadzić adres e-mail odbiorcy")]
[RegularExpression(".*@.*\\..*", ErrorMessage = "Zły format")]
[Display(Name = "Adres odbiorcy")]
[EmailAddress(ErrorMessage ="Zły format")]
@ -29,5 +30,16 @@ 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)
{
this.Content = DTO.Content;
this.EMailTo = DTO.EMailTo;
this.Subject = DTO.Subject;
}
}
}

View File

@ -1,10 +0,0 @@
namespace MailSender
{
public class Settings
{
public static string smtpServer = "smtp.gmail.com";
public static int smtpPort = 587;
public static string user = "ttestowy504@gmail.com";
public static string pass = "ChyzySoftware";
}
}

View File

@ -4,28 +4,30 @@
}
@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))
{
<div class="form-group">
@Html.LabelFor(i => i.Subject, new { @class = "label-form" })
@Html.EditorFor(i => i.Subject, new { htmlAttributes = new { @value = Model.Subject, @class = "form-control form-emailsend", @placeholder = "Temat" } })
@Html.EditorFor(i => i.Subject, new { htmlAttributes = new { @value = Model.Subject, @class = "form-control form-emailsend w100", @placeholder = "Temat" } })
@Html.ValidationMessageFor(i => i.Subject)
</div>
<div class="form-group">
@Html.LabelFor(i => i.EMailTo, new { @class = "label-form" })
@Html.EditorFor(i => i.EMailTo, new { htmlAttributes = new { @value = Model.EMailTo, @class = "form-control form-emailsend", @placeholder = "Do" } })
@Html.EditorFor(i => i.EMailTo, new { htmlAttributes = new { @value = Model.EMailTo, @class = "form-control form-emailsend w100", @placeholder = "Do" } })
@Html.ValidationMessageFor(i => i.EMailTo)
</div>
<div class="form-group" >
@Html.LabelFor(i => i.Content, new { @class = "label-form" })
@Html.EditorFor(i => i.Content, new { htmlAttributes = new { @value = Model.Content, @class = "form-control", @id = "exampleFormControlTextarea3", @rows=9, @placeholder = "Odpowiedź" } })
@Html.EditorFor(i => i.Content, new { htmlAttributes = new { @value = Model.Content, @class = "form-control w100", @id = "exampleFormControlTextarea3", @rows=9, @placeholder = "Odpowiedź" } })
@Html.ValidationMessageFor(i => i.Content)
</div>

View File

@ -20,10 +20,8 @@
@Html.ActionLink("E-mail", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Strona Główna", "Index", "Home")</li>
<li>@Html.ActionLink("O mnie", "About", "Home")</li>
<li>@Html.ActionLink("Kontakt", "Contact", "Home")</li>
<ul class="nav navbar-nar">
</ul>
</div>
</div>

View File

@ -10,6 +10,11 @@
</configSections>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="user-mail" value="ttestowy504@gmail.com" />
<add key="pass-mail" value="ChyzySoftware" />
<add key="smtp-port" value="587" />
<add key="smtp-server" value="smtp.gmail.com" />
<add key="forum-address" value="http://forum-inzynieria1.azurewebsites.net/home/index"/>
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
@ -65,7 +70,12 @@
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers></system.webServer>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>

View File

@ -19,6 +19,8 @@
<package id="Microsoft.AspNet.TelemetryCorrelation" version="1.0.0" targetFramework="net461" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net461" />
<package id="Microsoft.AspNet.Web.Optimization.pl" version="1.1.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebPages" version="3.2.4" targetFramework="net461" />
<package id="Microsoft.AspNet.WebPages.pl" version="3.2.4" targetFramework="net461" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.0" targetFramework="net461" />
@ -29,5 +31,6 @@
<package id="Newtonsoft.Json" version="11.0.1" targetFramework="net461" />
<package id="Owin" version="1.0" targetFramework="net461" />
<package id="System.Diagnostics.DiagnosticSource" version="4.4.1" targetFramework="net461" />
<package id="System.Web.Http.Common" version="4.0.20126.16343" targetFramework="net461" />
<package id="WebGrease" version="1.6.0" targetFramework="net461" />
</packages>