Guest User

Untitled

a guest
Jan 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 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()" 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. var idMessage;
  27. function GetMessageId() {
  28. var messageId = document.getElementById('clickId');
  29. idMessage = messageId.getAttribute('data-id');
  30.  
  31. $.ajax({
  32. type: 'POST',
  33. url: '@Url.Action("OrderStatus", "OrderEmployees")',
  34. data: {
  35. idMessage: idMessage
  36. },
  37. success: function (data) {
  38. console.log('success!');
  39. }
  40. });
  41. }
  42.  
  43. public ActionResult OrderStatus(string idMessage)
  44. {
  45. var messageId = _context.OrderEmployees.SingleOrDefault(m => m.Id == idMessage);
  46. if (messageId != null && messageId.Status == "New")
  47. {
  48. messageId.Status = "Open";
  49. _context.Update(messageId);
  50. _context.SaveChanges();
  51. }
  52.  
  53. return RedirectToAction(nameof(Index));
  54. }
Add Comment
Please, Sign In to add comment