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
- @{
- ViewBag.Title = "Tekrar Ara";
- string userRols = ViewBag.userRoler;
- int i = 1;
- }
- method="get">
- "text" name="date" id="date" class="form-control" />
- "submit" value="Getir" />
- "display:none;">@DateTime.UtcNow.AddHours(3).AddMinutes(5).ToString("dd/MM/yyy")
class="table">
- "font-size:medium;padding-left:15px;">Ad
- "font-size:medium;">Telefon
- Mail
- "font-size:medium;">Durum
"color:red;font-size:medium;width:20%;text-align:center;"> - "font-size:medium;">Aranacak Tarih
- "font-size:medium;">Notu
- @if (userRols == "admin")
- {
- "font-size:medium;">Sorumlu TMK
- }
- @foreach (var item in Model)
- {
- @i
"padding-left:20px;"> - @item.flowName
- @item.flowPhone
- @item.flowEMail
- @item.firstStatusText
"text-align:center;"> - @Convert.ToDateTime(item.callDate).ToString("dd/MM/yyy")
- "margin-left:10px;">@item.tekrarSaat
- @item.notes
- @if (userRols == "admin")
- {
- @item.tmkName
- }
- @Html.ActionLink("Çagri Aç", "Edit", "flows",new { id = item.flowId }, new { target = "_blank" })
- i++;
- }
- 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());
- }
- }
- }
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Yasin KızıltaşPosted Nov 27, 2018, 2:39 AM
Kalyani ShevalePosted Nov 26, 2018, 10:39 PM