Skip to content

Commit

Permalink
Admin Changes and Article result Implement
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebwar Hosain Poori authored and Rebwar Hosain Poori committed May 13, 2019
1 parent b0a5dea commit 65f3a0a
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class HelpDeskDbContextFactory : IDesignTimeDbContextFactory<HelpDeskCont
public HelpDeskContext CreateDbContext(string[] args)
{
var builder = new DbContextOptionsBuilder<HelpDeskContext>();
builder.UseSqlServer(@"Server=.;Database=HelpDesk;Integrated security=true");
builder.UseSqlServer(@"Server=(localdb)\ProjectsV13;Database=HelpDesk;Integrated security=true");
return new HelpDeskContext(builder.Options);
}
}
Expand Down
9 changes: 0 additions & 9 deletions HelpDesk.MVC/Controllers/AdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ public IActionResult AddCategory()
}
public IActionResult UploadCatImage(IFormFile files)
{
//"upload\\userimage\\normalimage\\"
//"\\upload\\userimage\\thumbnailimage\\"
string newFileName = uploadFileRepository.UplaodFile(files, "\\Images\\Category\\");
return Json(new { status = "success", message = "تصویر با موفقیت آپلود شد.", imagename = newFileName });
}
Expand Down Expand Up @@ -174,12 +172,6 @@ public ActionResult AddArticle(AddNewArticleGetViewModel model)

if ((model?.Image?.Length > 0) && ((model?.Image?.ContentType == "image/jpeg") || (model?.Image?.ContentType == "image/jpg")))
{
//string path_root = _hostingEnvironment.WebRootPath;
//string path_to_image = path_root + "\\Images\\" + model.Image.FileName;
//using (var stream = new FileStream(path_to_image, FileMode.Create))
//{
// await model.Image.CopyToAsync(stream);
//}
FileName = uploadFileRepository.UplaodFile(model.Image, "\\Images\\");
article.Image = @"~/images/" + FileName;
}
Expand Down Expand Up @@ -354,7 +346,6 @@ public void Upload2222(string name, int request)
{
var name2 = name;
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Upload(IFormFile file, Article article, string name, int request)
Expand Down
10 changes: 8 additions & 2 deletions HelpDesk.MVC/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using HelpDesk.MVC.Models.Login;
using Microsoft.AspNetCore.Identity;
using HelpDesk.MVC.Models.Users;
using HelpDesk.MVC.Models.Articles;

namespace HelpDesk.MVC.Controllers
{
Expand Down Expand Up @@ -85,11 +86,16 @@ public IActionResult SearchResult(string term = "")
public IActionResult SearchDetail(int id)
{
var model = articleRepository.Get(id);
DisplayArticle displayArticle = new DisplayArticle();
Article article = new Article();
article = model;
article.ViewCount = article.ViewCount + 1;
article.ViewCount = article.ViewCount + 1;
articleRepository.Update(model);
return View(model);
displayArticle.ResultArticle = article;
//displayArticle.ResultArticle = model;
displayArticle.Articles=articleRepository.GetAll().Take(2).ToList();

return View(displayArticle);
}
public IActionResult Login()
{
Expand Down
7 changes: 7 additions & 0 deletions HelpDesk.MVC/Models/Articles/AddNewArticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class AddNewArticle
public string VideoPath { get; set; }
public string PDFPath { get; set; }
public IFormFile PDF { get; set; }
public string CategoryName { get; set; }

}
public class DisplayArticleCategory:AddNewArticle
Expand All @@ -40,4 +41,10 @@ public class AddNewArticleGetViewModel : AddNewArticle
{
public int SelectedCat { get; set; }
}
public class DisplayArticle: AddNewArticle
{
public List<Article> Articles { get; set; }
public Article ResultArticle { get; set; }

}
}
2 changes: 1 addition & 1 deletion HelpDesk.MVC/Views/Admin/UserList.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
<td>@item.Email</td>
<td>@item.PhoneNumber</td>
<td><span class="label label-success">تایید شده</span></td>
<tr></tr>

}
<tr></tr>
</tbody>
</table>
</div>
Expand Down
133 changes: 75 additions & 58 deletions HelpDesk.MVC/Views/Home/SearchDetail.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@model HelpDesk.Domain.Core.Articles.Article
@*@model HelpDesk.Domain.Core.Articles.Article*@
@model HelpDesk.MVC.Models.Articles.DisplayArticle
@{
ViewData["Title"] = "SearchDetail";
Layout = "~/Views/Shared/_Layout.cshtml";
Expand All @@ -10,91 +11,107 @@
}

<section class="content">
<div class="section-title">
@*<span>خدمات</span>
<h3>ما بهترین خدمات برای مشتریان شما را ارائه می دهیم</h3>
<p>لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است. </p>*@
<div class="s130">
<div class="form">
<div class="inner-form">
<div>
<div class="svg-wrapper">
<form asp-action="SearchDetail" asp-controller="Home" method="post">

<div class="section-title">

@*<span>خدمات</span>
<h3>ما بهترین خدمات برای مشتریان شما را ارائه می دهیم</h3>
<p>لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است. </p>*@
<div class="row mb-2">
@foreach (var item in Model.Articles)
{
<div class="col-md-6">
<div class="card flex-md-row mb-4 box-shadow h-md-250">
<div class="card-body d-flex flex-column align-items-start">
<strong class="d-inline-block mb-2 text-primary">@item.Title</strong>
<div class="mb-1 text-muted">@item.PublishDate</div>
<div class="text-right">
<p class="card-text mb-auto" style="text-align:right">@item.Abstract</p>
</div>
<div class="text-left">
<a asp-action="SearchDetail" asp-route-id="@item.Id" class="text-left">ادامه مطلب</a>

</div>
</div>
@if (item.Image != null)
{
<img class="card-img-right flex-auto d-none d-md-block" data-src="@item.Image" alt="200x250" style="width: 200px; height: 250px;" asp-append-version="true" src="@item.Image">
}
else
{
<img class="card-img-right flex-auto d-none d-md-block" alt="200x250" style="width: 200px; height: 250px;" src="~/Images/Books_Icon_200x250.png" data-holder-rendered="true">
}
</div>
</div>
<div>
</div>
</div>
</div>
</div>

</div>
<div class="row">
<div class="col-md-12">
<div>

<div class="box-body clearfix">
}
</div>

<div class="form-group">
<p>@Model.Title</p>
</div>
<div class="form-group">
<img class="img-bordered-sm" style="max-width:50%" src="@Model.Image" asp-append-version="true" />
</div>
</div>
<div class="row">
<div class="col-md-12">
<div>

<div class="form-group">
<label class="control-label ">تاریخ انتشار:</label>
<div class="box-body clearfix">

<label class="control-label input-lg">@Model.PublishDate</label>
<div class="form-group">
<p>@Model.ResultArticle.Title</p>
</div>
<div class="form-group">
<img class="img-bordered-sm" style="max-width:50%" src="@Model.ResultArticle.Image" asp-append-version="true" />
</div>

<div class="form-group">
<label class="control-label ">تاریخ انتشار:</label>

<label class="control-label input-lg">@Model.ResultArticle.PublishDate</label>

</div>

<div class="form-group">
<label class="control-label">گروه:</label>

<label class="control-label input-lg">@ViewData["Category"]</label>
</div>
</div>

<div class="form-group">
<blockquote class="pull-right"> <p>@Model.Abstract</p></blockquote>

</div>
<div class="box-body pad">
<p>@Html.Raw(@Model.Body)</p>
</div>
@if (Model.Video != null)
{
<div class="form-group">
<video id="vedioPlayer" src="@Url.Content(@Model.Video)" controls="controls" style="width:50%"></video>
</div>
}
<blockquote class="pull-right"> <p>@Model.ResultArticle.Abstract</p></blockquote>

@if (Model.PDF != null)
{
</div>
<div class="box-body pad">
<p>@Html.Raw(@Model.ResultArticle.Body)</p>
</div>
@if (Model.ResultArticle.Video != null)
{
<div class="form-group">
<video id="vedioPlayer" src="@Url.Content(@Model.ResultArticle.Video)" controls="controls" style="width:50%"></video>
</div>
}

@if (Model.ResultArticle.PDF != null)
{
<div class="form-group">
<a href="@Url.Content(@Model.ResultArticle.PDF)" class="btn btn-primary" target="_blank">مشاهده ضمیمه</a>
</div>
}
<div class="form-group">
<a href="@Url.Content(@Model.PDF)" class="btn btn-primary" target="_blank">مشاهده ضمیمه</a>
<p>
تعداد بازدید مطلب: @Model.ResultArticle.ViewCount
</p>
</div>
}
<div class="form-group">
<p>
تعداد بازدید مطلب: @Model.ViewCount
</p>
</div>
<form asp-action="SearchDetail" asp-controller="Home" method="post">
<div class="form-group">
<button type="submit" class="btn btn-app">مطلب را پسندیدم</button>
</div>


</form>

</div>
</div>

</div>


</div>
</div>

</form>
</section>


Expand Down
2 changes: 1 addition & 1 deletion HelpDesk.MVC/Views/Shared/_NavBar.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item"><a class="nav-link active" href="#home">خانه</a></li>
<li class="nav-item"><a asp-action="Index" asp-controller="Home" class="nav-link active">خانه</a></li>
<li class="nav-item"><a class="nav-link" href="#about">درباره ما</a></li>
<li class="nav-item"><a class="nav-link" href="contact.html">تماس با ما</a></li>
<li class="nav-item"><a class="nav-link" asp-action="Login" asp-controller="Home">ورود</a></li>
Expand Down
4 changes: 2 additions & 2 deletions HelpDesk.MVC/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ConnectionStrings": {
"HelpDesk": "Server=.;initial catalog=HelpDesk;Integrated Security=True;MultipleActiveResultSets=true",
"UserDb": "Server=.;Database=UserDB;Integrated Security=True;MultipleActiveResultSets=true"
"HelpDesk": "Server=(localdb)\\ProjectsV13;initial catalog=HelpDesk;Integrated Security=True;MultipleActiveResultSets=true",
"UserDb": "Server=(localdb)\\ProjectsV13;Database=UserDB;Integrated Security=True;MultipleActiveResultSets=true"
//(localdb)\\ProjectsV13
},
"ImageRoot": "/Images/Content/",
Expand Down
Binary file added HelpDesk.MVC/wwwroot/Images/Books_Icon_200x250.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 65f3a0a

Please sign in to comment.