Guest User

Untitled

a guest
Feb 8th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.90 KB | None | 0 0
  1. public class PostTypeCategoryVM
  2. {
  3. public int PostId { get; set; }
  4. public int? PostParentId { get; set; }
  5. public Post post { get; set; }
  6. public int PostTypeId { get; set; }
  7. //[Required]
  8. public string PostType { get; set; }
  9. //[Required]
  10. public DateTime PublishDate { get; set; }
  11. //[Required]
  12. public DateTime UnPublishDate { get; set; }
  13. [Required]
  14. public List<string> SelectedCategories { get; set; }
  15. [Required]
  16. public int selectedStatus { get; set; }
  17. public List<PostStatusVM> PostStatus { get; set; }
  18. [Required]
  19. public List<PostTypeVM> PostCategories { get; set; }
  20. //[Required]
  21.  
  22. public List<PostDetailVM> PostDetailVM { get; set; }
  23.  
  24. public class PostDetailVM
  25. {
  26.  
  27. [PostTitle]
  28. public string Title { get; set; }
  29. [Required]
  30. public string Content { get; set; }
  31. public int LangId { get; set; }
  32. [Required]
  33. public string Slug {get;set;}
  34.  
  35. public class PostTitleAttribute : ValidationAttribute
  36. {
  37.  
  38.  
  39.  
  40. protected override ValidationResult IsValid(object value,
  41. ValidationContext validationContext)
  42. {
  43.  
  44. var lang = (PostDetailVM)validationContext.ObjectInstance;
  45.  
  46. if (lang.LangId==1 && string.IsNullOrEmpty(lang.Title))
  47. {
  48. return new ValidationResult("English Title is required");
  49.  
  50. }
  51. if (lang.LangId == 2 && string.IsNullOrEmpty(lang.Title))
  52. {
  53. return new ValidationResult("Darri Title is required");
  54.  
  55. }
  56. return ValidationResult.Success;
  57.  
  58. }
  59.  
  60.  
  61. }
  62.  
  63. @model SepiaCMS.Models.PostTypeCategoryVM
  64. <div>@Html.ValidationSummary("Please correct below Errors")</div>
  65. <div class="container">
  66. <div class="col-md-12">
  67. <div id="appendView">
  68. </div>
  69. </div>
  70.  
  71. <div class="col-md-6">
  72. <ul class="nav nav-tabs" id="tabs">
  73.  
  74. @foreach (var item in (IEnumerable<SepiaCMS.Models.lang>)ViewBag.Languages)
  75. {
  76. if (i == 0)
  77. {
  78.  
  79. <li class="nav active"><a href="#@item.langid" data-toggle="tab"><label><input type="checkbox" checked="checked" name="IsCheck" />&nbsp;@item.langname</label></a></li>
  80. }
  81. else
  82. {
  83. <li class="nav"><a href="#@item.langid" data-toggle="tab"><input type="checkbox" name="IsCheck" checked="checked" />&nbsp;@item.langname</a></li>
  84. }
  85. { i = i + 1; }
  86. }
  87. </ul>
  88.  
  89. <!-- Tab panes -->
  90.  
  91. <div class="tab-content">
  92. @{int kk = 0; }
  93. @foreach (var item in (IEnumerable<SepiaCMS.Models.lang>)ViewBag.Languages)
  94. {
  95. if (k == 0)
  96. {
  97.  
  98. <div class="tab-pane fade in active" id="@item.langid">
  99.  
  100. <span>Post Title</span><br />
  101.  
  102. @Html.TextBoxFor(m => m.PostDetailVM[kk].Title, new { @id = "lang-" + item.langid, @class = "txtfortitle" })<br />
  103. @*@Html.ValidationMessageFor(m => m.PostDetailVM[kk].Title, "*", new { @class = "text-danger" })*@
  104. <span>Description</span><br />
  105. @Html.TextAreaFor(m => m.PostDetailVM[kk].Content, 20, 10, new { @class = "txtForPost" })
  106. @*@Html.ValidationMessageFor(m => m.PostDetailVM[kk].Content, "", nejjw { @class = "text-danger" })*@
  107. @Html.LabelFor(m => m.PostDetailVM[kk].Slug, "Enter Slug")
  108. @Html.TextBoxFor(m => m.PostDetailVM[kk].Slug, new { @class = "txtslug" })
  109. @*@Html.ValidationMessageFor(m => m.PostDetailVM[kk].Slug, "", new { @class = "text-danger" })*@
  110. <input type="hidden" name="PostDetailVM[@kk].LangId" value="@item.langid" />
  111. @*<input type="button" value="Done" class="btn btn-success" id="btnSubmit" />
  112. <a href="#" class="btn btn-default" data-dismiss="modal">Cancel</a>*@
  113. <div style="text-align:center;display:none" id="loaderDiv">
  114. <img src="~/Content/InternetSlowdown_Day.gif" width="150" />
  115. </div>
  116. </div>
  117.  
  118. }
  119. else
  120. {
  121. <div class="tab-pane fade" id="@item.langid">
  122. <span>Post Title</span><br />
  123. @Html.TextBoxFor(m => m.PostDetailVM[kk].Title, new { @id = "lang-" + item.langid, @class = "txtfortitle" })<br />
  124. @*@Html.ValidationMessageFor(m => m.PostDetailVM[kk].Title, "", new { @class = "text-danger" })*@
  125. <span>Description</span><br />
  126. @Html.TextAreaFor(m => m.PostDetailVM[kk].Content, 20, 10, new { @class = "txtForPost" })
  127. @*@Html.ValidationMessageFor(m => m.PostDetailVM[kk].Content, "", new { @class = "text-danger" })*@
  128. @Html.LabelFor(m => m.PostDetailVM[kk].Slug, "Enter Slug")
  129. @Html.TextBoxFor(m => m.PostDetailVM[kk].Slug, new { @class = "txtslug" })
  130. @*@Html.ValidationMessageFor(m => m.PostDetailVM[kk].Slug, "", new { @class = "text-danger" })*@
  131. <input type="hidden" name="PostDetailVM[@kk].LangId" value="@item.langid" />
  132. @*<input type="button" value="Done" class="btn btn-success" id="btnSubmit" />
  133. <a href="#" class="btn btn-default" data-dismiss="modal">Cancel</a>*@
  134. <div style="text-align:center;display:none" id="loaderDiv">
  135. <img src="~/Content/InternetSlowdown_Day.gif" width="150" />
  136. </div>
  137. </div>
  138. }
  139. { k = k + 1; }
  140. { kk = kk + 1; }
  141. }
Add Comment
Please, Sign In to add comment