Dodano zapisywanie odpowiedzi jako profesionalista

This commit is contained in:
Bartosz Chyży 2018-12-18 13:39:47 +01:00
parent 70bdf02761
commit c1a6d311e0
6 changed files with 110 additions and 77 deletions

View File

@ -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)
{

View File

@ -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);

View File

@ -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

View File

@ -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">

View File

@ -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">

View File

@ -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">