Skip to content

Commit d2e8c95

Browse files
committed
Working search
1 parent 5a60c89 commit d2e8c95

18 files changed

+8
-7
lines changed

EPAM.MyBlog.DAL.DB/DAL.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,8 @@ public bool AddAvatar(Entities.Avatar avatar)
729729
{
730730
using (SqlConnection con = new SqlConnection(ConnectionString))
731731
{
732-
SqlCommand command = new SqlCommand("SELECT dbo.Posts.Post_Id, dbo.Posts.Post_Title FROM dbo.Posts INNER JOIN dbo.Tags ON dbo.Tags.Post_Id = dbo.Posts.Post_Id WHERE CONTAINS(Tag, @Tag)", con);
733-
command.Parameters.Add("@Tag", p);
732+
SqlCommand command = new SqlCommand("SELECT [Blog].dbo.Posts.Post_Id,[Blog].dbo.Posts.Post_Title FROM [Blog].dbo.Posts INNER JOIN [Blog].dbo.Tags ON [Blog].dbo.Tags.Post_Id = [Blog].dbo.Posts.Post_Id WHERE Tag LIKE @Tag", con);
733+
command.Parameters.Add(new SqlParameter("@Tag", p));
734734
con.Open();
735735
var reader = command.ExecuteReader();
736736

@@ -751,8 +751,8 @@ public bool AddAvatar(Entities.Avatar avatar)
751751
{
752752
using (SqlConnection con = new SqlConnection(ConnectionString))
753753
{
754-
SqlCommand command = new SqlCommand("SELECT dbo.Posts.Post_Id, dbo.Posts.Post_Title FROM dbo.Posts INNER JOIN dbo.Tags ON dbo.Tags.Post_Id = dbo.Posts.Post_Id WHERE CONTAINS(Post_Text, @Text)", con);
755-
command.Parameters.Add("@Text", p);
754+
SqlCommand command = new SqlCommand("SELECT [Post_Id], [Post_Title] FROM [Blog].dbo.Posts WHERE Post_Text LIKE @Text", con);
755+
command.Parameters.Add(new SqlParameter("@Text", p));
756756
con.Open();
757757
var reader = command.ExecuteReader();
758758

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

EPAM.MyBlog.UI.Web/Controllers/SearchController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ public ActionResult Index(SearchModel model)
3131

3232
}
3333

34-
[HttpPost]
34+
3535
public ActionResult Result(string search)
3636
{
3737
SearchModel model = new SearchModel();
38+
model.SearchText = search;
3839
var result = model.GetResult();
3940
return View(result);
4041
}

EPAM.MyBlog.UI.Web/Logs/Debug/2015.01.12.log

Whitespace-only changes.

EPAM.MyBlog.UI.Web/Logs/Errors/2015.01.12.log

Whitespace-only changes.

EPAM.MyBlog.UI.Web/Models/SearchModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal IEnumerable<PresentPostModel> GetResult()
2626
string query = SearchText.Trim();
2727
if(query.Substring(0,1) == "#")
2828
{
29-
var result = GetDAL.dal.GetResultOfSearchTag(this.SearchText).ToList();
29+
var result = GetDAL.dal.GetResultOfSearchTag(this.SearchText.Substring(1,SearchText.Length-1)).ToList();
3030
List<PresentPostModel> TitleList = new List<PresentPostModel>();
3131
foreach (var item in result)
3232
{

EPAM.MyBlog.UI.Web/Views/Search/Result.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
grid.Column("",
1313
header: "",
1414
format: @<text>
15-
@Html.ActionLink("Читать", "Posts", new { id=item.Id })
15+
@Html.ActionLink("Читать", "Posts", "Post", new { id=item.Id }, null)
1616
</text>
1717
)
1818
})
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.

EPAM.MyBlog.v11.suo

84.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)