Guest User

Untitled

a guest
Jan 20th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. @foreach (var item in Model)
  2. {
  3. if (item.Status == "New")
  4. {
  5. <div class="panel panel-default" data-id="@item.Id" onclick="GetMessageId(this)" id="clickId">
  6. <div class="panel-heading">
  7. <a class="btn btn-success" data-toggle="collapse" href="#imageGallery-@item.Id" style="width: 100%">
  8. <h4 style="color: white; text-align: left; width: auto; z-index: 3">
  9. От: @Html.DisplayFor(modelItem => item.EmployeeTo.Name) -
  10. <strong> @Html.DisplayFor(modelItem => item.Title)</strong>
  11. </h4>
  12. </a>
  13. </div>
  14. <div class="panel-body collapse" id="imageGallery-@item.Id">
  15. <strong style="color: dimgrey">Заголовок:</strong><h5> @Html.DisplayFor(modelItem => item.Title)</h5><br />
  16. <div style="width: 100%">
  17. <strong style="color: dimgrey">Содержимое</strong> <h4>@Html.DisplayFor(modelItem => item.Content)</h4>
  18. </div> <br /><hr />
  19. <p style="color: dimgrey">Дата отправки: @Html.DisplayFor(modelItem => item.DateFrom) </p>
  20. <a class="btn btn-primary" onclick="showModalSendOrderAdmin()">Переслать</a>
  21. </div>
  22. </div>
  23. }
  24. }
  25.  
  26.  
  27. @foreach (var item in Model)
  28. {
  29. if (item.Status == "Open")
  30. {
  31. <div class="panel panel-default" data-id="@item.Id" onclick="GetMessageIdOpen(this)">
  32. <div class="panel-heading">
  33. <a class="btn btn-info" data-toggle="collapse" id="clickIdOpen" href="#imageGallery-@item.Id" style="width: 100%">
  34. <h4 style="color: white; text-align: left; width: auto; z-index: 3">
  35. От: @Html.DisplayFor(modelItem => item.EmployeeTo.Name) -
  36. <strong > @Html.DisplayFor(modelItem => item.Title)</strong>
  37. </h4>
  38. </a>
  39. </div>
  40. <div class="panel-body collapse" id="imageGallery-@item.Id">
  41. <strong style="color: dimgrey">Заголовок:</strong><h5> @Html.DisplayFor(modelItem => item.Title)</h5><br />
  42. <div style="width: 100%">
  43. <strong style="color: dimgrey">Содержимое</strong> <h4>@Html.DisplayFor(modelItem => item.Content)</h4>
  44. </div> <br /><hr/>
  45. <p style="color: dimgrey">Дата отправки: @Html.DisplayFor(modelItem => item.DateFrom) </p>
  46. <p style="color: dimgrey">Отправленно администратору: @Html.DisplayFor(modelItem => item.DateTo) </p>
  47.  
  48. <a class="btn btn-primary" onclick="showModalSendOrderAdmin()">Переслать</a>
  49.  
  50. </div>
  51. </div>
  52. }
  53. }
  54.  
  55. var idMessage;
  56. function GetMessageId(event) {
  57.  
  58. idMessage = event.getAttribute('data-id');
  59.  
  60. $.ajax({
  61. type: 'POST',
  62. url: '@Url.Action("OrderStatus", "OrderEmployees")',
  63. data: {
  64. idMessage: idMessage
  65. },
  66. success: function (data) {
  67. console.log('success!');
  68. }
  69. });
  70. }
  71.  
  72.  
  73. var idMessageOpen;
  74. function GetMessageIdOpen(event) {
  75. idMessageOpen = event.getAttribute('data-id');
  76.  
  77. $.ajax({
  78. type: 'POST',
  79. url: '@Url.Action("OrderStatusOpen", "OrderEmployees")',
  80. data: {
  81. idMessageOpen: idMessageOpen
  82. },
  83. success: function (data) {
  84. console.log('success!');
  85. }
  86. });
  87. }
  88.  
  89. public ActionResult OrderStatus(string idMessage)
  90. {
  91. var messageId = _context.OrderEmployees.SingleOrDefault(m => m.Id == idMessage);
  92. if (messageId != null && messageId.Status == "New")
  93. {
  94. messageId.Status = "Open";
  95. _context.Update(messageId);
  96. _context.SaveChanges();
  97. }
  98.  
  99. return RedirectToAction(nameof(Index));
  100. }
  101.  
  102.  
  103.  
  104. public ActionResult OrderStatus(string idMessage)
  105. {
  106. var messageId = _context.OrderEmployees.SingleOrDefault(m => m.Id == idMessage);
  107. if (messageId != null && messageId.Status == "New")
  108. {
  109. messageId.Status = "Open";
  110. _context.Update(messageId);
  111. _context.SaveChanges();
  112. }
  113.  
  114. return RedirectToAction(nameof(Index));
  115. }
Add Comment
Please, Sign In to add comment