Dodano zapisywanie odpowiedzi jako profesionalista
This commit is contained in:
parent
70bdf02761
commit
c1a6d311e0
@ -151,7 +151,7 @@ namespace Forum.Controllers
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ using System.Web.Mvc;
|
||||
using Forum.DataAccessLayer;
|
||||
using Forum.DataAccessLayer.Models;
|
||||
using Forum.ViewModels;
|
||||
using Microsoft.AspNet.Identity;
|
||||
|
||||
namespace Forum.Controllers
|
||||
{
|
||||
@ -99,11 +100,14 @@ 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);
|
||||
|
@ -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 = "Imie i nazwisko")]
|
||||
[Required]
|
||||
public string FullName { get; set; }
|
||||
}
|
||||
|
||||
public class ResetPasswordViewModel
|
||||
|
@ -17,6 +17,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">
|
||||
|
@ -15,7 +15,16 @@
|
||||
{
|
||||
|
||||
<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 = "Nazwa użytkownika" } })
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
@ -1,4 +1,5 @@
|
||||
@model Forum.DataAccessLayer.Models.Question
|
||||
@using WebGrease.Css.Extensions
|
||||
@model Forum.DataAccessLayer.Models.Question
|
||||
|
||||
@{
|
||||
ViewBag.Title = @Model.Title;
|
||||
@ -30,7 +31,16 @@
|
||||
{
|
||||
<li class="answer-list__single-answer">
|
||||
<div class="answer-list__answer__info" >
|
||||
@{
|
||||
if (answer.Professional != null)
|
||||
{
|
||||
<span class="username">@answer.Professional.FullName napisał(a)</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="username">@answer.Nick napisał(a)</span>
|
||||
}
|
||||
}
|
||||
@answer.Date
|
||||
</div>
|
||||
<div class="answer-list__content">
|
||||
|
Loading…
Reference in New Issue
Block a user