TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Yasin Kızıltaş
NA
57
4.7k
How do I prevent data repetition in mvc?
Nov 26 2018 8:29 AM
Hello there. I am drawing data from the database according to a certain condition. however, the query repeats data in some cases and lists duplicate data. How do I prevent this?
TekrarAraV View;
@model IEnumerable<cmsV0._1.Models.vw_get_callLog>
@{
ViewBag.Title =
"Tekrar Ara"
;
string userRols = ViewBag.userRoler;
int
i = 1;
}
<br />
<form action=
"/Rapor/TekrarAraV"
method=
"get"
>
<input type=
"text"
name=
"date"
id=
"date"
class
=
"form-control"
/>
<input type=
"submit"
value=
"Getir"
/>
</form>
<div style=
"display:none;"
>@DateTime.UtcNow.AddHours(3).AddMinutes(5).ToString(
"dd/MM/yyy"
)</div>
<br /><br />
<table
class
=
"table"
>
<thead>
<tr>
<th></th>
<td>
<b style=
"font-size:medium;padding-left:15px;"
>Ad</b>
</td>
<td>
<b style=
"font-size:medium;"
>Telefon</b>
</td>
<td>
<b>Mail</b>
</td>
<td>
<b style=
"font-size:medium;"
>Durum</b>
</td>
<td style=
"color:red;font-size:medium;width:20%;text-align:center;"
>
<b style=
"font-size:medium;"
>Aranacak Tarih</b>
</td>
<td>
<b style=
"font-size:medium;"
>Notu</b>
</td>
@
if
(userRols ==
"admin"
)
{
<td>
<b style=
"font-size:medium;"
>Sorumlu TMK</b>
</td>
}
</tr>
@foreach (
var
item
in
Model)
{
<tr>
<td>
@i
</td>
<td style=
"padding-left:20px;"
>
@item.flowName
</td>
<td>
@item.flowPhone
</td>
<td>
@item.flowEMail
</td>
<td>
@item.firstStatusText
</td>
<td style=
"text-align:center;"
>
@Convert.ToDateTime(item.callDate).ToString(
"dd/MM/yyy"
)
<span style=
"margin-left:10px;"
>@item.tekrarSaat</span>
</td>
<td>
@item.notes
</td>
@
if
(userRols ==
"admin"
)
{
<td>
@item.tmkName
</td>
}
<td>
@Html.ActionLink(
"Çagri Aç"
,
"Edit"
,
"flows"
,
new
{ id = item.flowId },
new
{ target =
"_blank"
})
</td>
</tr>
i++;
}
</thead>
</table>
<script>
function
filterDate() {
var
input, filter, table, tr, td, i;
input = document.getElementById(
"flowSearchN"
);
filter = input.value.toUpperCase();
table = document.getElementById(
"calendarM"
);
tr = table.getElementsByTagName(
"tr"
);
for
(i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName(
"td"
)[3];
if
(td) {
if
(td.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display =
""
;
}
else
{
tr[i].style.display =
"none"
;
}
}
}
}
</script>
RaporController;
public
ActionResult TekrarAraV(DateTime? date)
{
userData = userControl(); ViewBag.uData = userData;
string
userName = userData.tmkName;
using
(smartCMSEntities ft =
new
smartCMSEntities())
{
string
userRol = userData.role;
ViewBag.userRoler = userRol;
if
(date ==
null
&& userRol ==
"admin"
)
{
return
View(ft.vw_get_callLog.Where(x => x.firstStatusText ==
"Tekrar Ara"
& x.callDate !=
null
& x.callDate == DateTime.Today).ToList());
}
else
if
(date ==
null
)
{
return
View(ft.vw_get_callLog.Where(x => x.firstStatusText ==
"Tekrar Ara"
& x.callDate !=
null
& x.tmkName == userName & x.callDate == DateTime.Today).ToList());
}
else
if
(userRol ==
"admin"
)
{
return
View(ft.vw_get_callLog.Where(x => x.firstStatusText ==
"Tekrar Ara"
& x.callDate !=
null
& x.callDate == date).ToList());
}
else
{
return
View(ft.vw_get_callLog.Where(x => x.firstStatusText ==
"Tekrar Ara"
& x.callDate !=
null
& x.tmkName == userName & x.callDate == date).ToList());
}
}
}
Reply
Answers (
2
)
How to install asp.net core application exe as windoes servi
What are new things to learn after 3 Years Exp in C# .Net?