Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.91 KB | None | 0 0
  1. @model EmailViewModel
  2.  
  3. @{
  4.     ViewData["Title"] = "ListAllEmails";
  5. }
  6.  
  7. <h2></h2>
  8. <table id="table_id" class="display">
  9.     <thead>
  10.         <tr>
  11.             <th>ID</th>
  12.             <th>Subject</th>
  13.             <th>ReceivedOn</th>
  14.             <th>Sender</th>
  15.             <th>Status</th>
  16.             <th>Attachment</th>
  17.             <th>Details</th>
  18.         </tr>
  19.     </thead>
  20. </table>
  21.  
  22. <!-- Modal -->
  23. <div class="modal fade" id="myModalNorm" tabindex="-1" role="dialog"
  24.      aria-labelledby="myModalLabel" aria-hidden="true">
  25.     <div class="modal-dialog">
  26.         <div class="modal-content">
  27.             <div class="modal-header">
  28.                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  29.                     <span aria-hidden="true">×</span>
  30.                 </button>
  31.             </div>
  32.             <!-- Modal Body -->
  33.             <div class="modal-body"></div>
  34.  
  35.             <div class="modal-footer">
  36.                 <form asp-controller="Email" asp-action="ChangeValidStatusAsync">
  37.                     <button type="button" class="btn btn-default" id="New" data-dismiss="modal">New</button>
  38.                 </form>
  39.                 <form asp-controller="Email" asp-action="ChangeInValidStatus">
  40.                 <button type="submit" class="btn btn-default" id="NotValid" data-dismiss="modal">Not Valid</button>
  41.                 </form>
  42.                 @if (User.IsInRole("Manager"))
  43.                 {
  44.                     @*<form asp-controller="Email" asp-action="ChangeStatus" asp-route-EmailId="@Model.Id" method="post">*@
  45.                     <button type="submit" class="btn btn-default">Not Reviewed</button>
  46.                     @*</form>*@
  47.                 }
  48.             </div>
  49.         </div>
  50.     </div>
  51. </div>
  52.  
  53. @section Scripts
  54.  
  55.     {
  56.     <link rel="stylesheet" type="text/css" href="~/lib/DataTables/datatables.css">
  57.     <script type="text/javascript" language="javascript" src="~/lib/DataTables/datatables.js"></script>
  58.     <script src="~/js/site.js"></script>
  59.     <script type="text/javascript" src="~/lib/toast-1.4/toast/toast.js"></script>
  60.     <link rel="stylesheet" type="text/css" href="~/lib/toast-1.4/toast/toast.css">
  61.     <script type="text/javascript" class="init">
  62.  
  63.         var table = $('#table_id').DataTable({
  64.             "ordering": false,
  65.             "processing": true,
  66.             "serverSide": true,
  67.             //"orderCellsTop": true,
  68.             //"fixedHeader": true,
  69.  
  70.             "ajax": {
  71.                 "url": "@Url.Action("ListAllEmails", "Email")",
  72.                 "type": 'POST',
  73.                 "dataType": "JSON",
  74.             },
  75.  
  76.             "columns": [
  77.                 { "data": "Id" },
  78.                 { "data": "Subject" },
  79.                 { "data": "ReceivedOn"},
  80.                 { "data": "MerchantEmail" },
  81.                 { "data": "EmailStatusType" },
  82.                 { "data" : "EmailAttachmentsCount",
  83.                     "render": function (data, type, row) {
  84.  
  85.                         if (row.EmailAttachmentsCount > 0) {
  86.                             return '<img src="/images/paperclip-vector-paper-clamp-3.png" style="width:18px" />';
  87.                         } else {
  88.                             return 'no attachments'
  89.                         }
  90.                     }
  91.                 },
  92.                 {
  93.                     "render": function (data, type, email, meta) {
  94.                         return '<button class="details" data-toggle="modal" data-target="#myModalNorm" data-emailid="' + email.Id + '">See more</button>';
  95.                    }
  96.                 }
  97.             ]
  98.         });
  99.  
  100.         $('#myModalNorm').on('shown.bs.modal', function (e) {
  101.             console.log(e);
  102.             var $modal = $(this);
  103.             $body = $modal.find(".modal-body");
  104.             var emailId = $(e.relatedTarget).data('emailid');
  105.             var url = "/Email/Details/" + emailId;
  106.             $.get(url)
  107.                 .done(function (responseData) {
  108.                     $body.html(responseData);
  109.                     console.log($('#New'));
  110.                     console.log($('#NotValid'))
  111.                     $('#New').data('emailId', emailId);
  112.                     $('#NotValid').data('emailId', emailId);
  113.                 })
  114.         })
  115.  
  116.         $(function () {
  117.             $('#New').click(function (e) {
  118.                 e.preventDefault();
  119.                 var id = $(this).data('emailId');
  120.  
  121.                 $.post("/Email/ChangeValidStatusAsync/", { emailId: id }, function (response) {
  122.                     console.log(response);
  123.                     $toast.success('Have fun storming the castle!', 'Miracle Max Says')
  124.                 });
  125.             });
  126.         });
  127.  
  128.        
  129.         $(function () {
  130.             $('#NotValid').click(function (e) {
  131.                 e.preventDefault();
  132.                 var id = $(this).data('emailId');
  133.  
  134.                 $.post("/Email/ChangeInValidStatusAsync/", { emailId: id }, function (response) {
  135.                     console.log(response);
  136.                     $toast.success('Have fun storming the castle!', 'Miracle Max Says')
  137.                 });
  138.             });
  139.         });
  140.  
  141.         //$(document).ready(function () {
  142.         //    "Subject, ReceivedOn, Sender, Status, Attachment, Details"
  143.         //    $('#table_id thead tr').clone(true).appendTo('#table_id thead');
  144.         //    $('#table_id thead tr:eq(1) th').each(function (i) {
  145.         //        var title = $(this).text();
  146.         //        $(this).html('<input type="text" placeholder="Search ' + title + '" />');
  147.  
  148.         //        $('input', this).on('keyup change', function () {
  149.         //            if (table.column(i).search() !== this.value) {
  150.         //                table
  151.         //                    .column(i)
  152.         //                    .search(this.value)
  153.         //                    .draw();
  154.         //            }
  155.         //        });
  156.         //    });
  157.         //});
  158.     </script>
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement