Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. {
  2. "sameLanguages":true,
  3. "sameDeadlines":true,
  4. "sameDeliverables":false,
  5. "quotations":[
  6. {
  7. "name":"zasd",
  8. "deliverable":"538184e1-9a62-4ce9-baa7-ed746f267a9a",
  9. "subtitleAssignments":{
  10. "languageCombinations":[
  11. {
  12. "from":"d177b276-8f10-472f-84c6-f2ef59052a09",
  13. "to":"d177b276-8f10-472f-84c6-f2ef59052a09",
  14. "startDate":"19-09-2017",
  15. "endDate":"19-09-2017"
  16. }
  17. ],
  18. "amount":12
  19. },
  20. "translationAssignments":{
  21. "languageCombinations":[
  22.  
  23. ]
  24. }
  25. }
  26. ]
  27. }
  28.  
  29. [HttpPost]
  30. public IActionResult Add([FromBody] SubmitQuotationsModel model)
  31. {
  32. //Do things...
  33. return View();
  34. }
  35.  
  36. public class SubmitQuotationsModel
  37. {
  38. public bool SameLanguages { get; set; }
  39. public bool SameDeadlines { get; set; }
  40. public bool SameDeliverables { get; set; }
  41. public List<SubmitQuotationModel> Quotations { get; set; } = new List<SubmitQuotationModel>();
  42. }
  43.  
  44. public class SubmitQuotationModel
  45. {
  46. public string Name { get; set; }
  47. public string Deliverable { get; set; }
  48. public List<AssignmentModel> SubtitleAssignments { get; set; }
  49. public List<AssignmentModel> TranslationAssignments { get; set; }
  50. }
  51.  
  52. public class AssignmentModel
  53. {
  54. public List<LanguageCombinationModel> LanguageCombinations { get; set; }
  55. public int Amount { get; set; }
  56. }
  57.  
  58. public class LanguageCombinationModel
  59. {
  60. public string From { get; set; }
  61. public string To { get; set; }
  62. public DateTimeOffset StartDate { get; set; }
  63. public DateTimeOffset EndDate { get; set; }
  64. }
  65.  
  66. fetch('/Quotation/Add', {
  67. method: 'POST',
  68. headers: {
  69. 'Content-Type': 'application/json'
  70. },
  71. credentials: 'include',
  72. body: this.toJSON()
  73. });
  74.  
  75. public toJSON(): string {
  76. let model = {
  77. sameLanguages: this.step1().sameLanguages(),
  78. sameDeadlines: this.step1().sameDeadlines(),
  79. sameDeliverables: this.step1().sameDeliverables(),
  80. quotations: this.step2().quotations().filter((q) => q.isFilledIn()).map((q) => {
  81. return {
  82. name: q.name(),
  83. deliverable: q.selectedDeliverable().id,
  84. subtitleAssignments: this.getAssignmentModel(q.subtitleAssignmentGroup()),
  85. translationAssignments: this.getAssignmentModel(q.translationAssignmentGroup())
  86. }
  87. })
  88. };
  89. return ko.toJSON(model);
  90. }
  91.  
  92. private getAssignmentModel(model: AssignmentGroupModel) {
  93. return {
  94. languageCombinations: model.assignments().map((a) => {
  95. return {
  96. from: a.fromLanguage().value,
  97. to: a.toLanguage().value,
  98. startDate: a.startDate().format('DD-MM-YYYY'),
  99. endDate: a.endDate().format('DD-MM-YYYY')
  100. }
  101. }),
  102. amount: model.amount()
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement