Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 KB | None | 0 0
  1. using ASP.Common.Data.DTO.REvolve;
  2. using System.Linq;
  3. //-------------------------------------------------------------------------------------------------------
  4. // <auto-generated>
  5. // This code was generated by EntitiesToDTOs.v3.3.0.0 (entitiestodtos.codeplex.com).
  6. // Timestamp: 2018.03.26 - 14:57:34
  7. //
  8. // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
  9. // </auto-generated>
  10. //-------------------------------------------------------------------------------------------------------
  11. using System.Collections.Generic;
  12. using ASP.Common.Data.Model;
  13. using System;
  14.  
  15. namespace ASP.Common.Data.ClientLoader.Assemblers.REvolve
  16. {
  17.  
  18. /// <summary>
  19. /// Assembler for <see cref="ControlActions"/> and <see cref="C_Control_ActionsDTO"/>.
  20. /// </summary>
  21. public static partial class ControlActionsAssembler
  22. {
  23. /// <summary>
  24. /// Invoked when <see cref="ToDTO"/> operation is about to return.
  25. /// </summary>
  26. /// <param name="dto"><see cref="C_Control_ActionsDTO"/> converted from <see cref="C_Control_Actions"/>.</param>
  27. static partial void OnDTO(this ControlActions model, C_Control_ActionsDTO dto);
  28.  
  29. /// <summary>
  30. /// Invoked when <see cref="ToModel"/> operation is about to return.
  31. /// </summary>
  32. /// <param name="model"><see cref="ControlActions"/> converted from <see cref="C_Control_ActionsDTO"/>.</param>
  33. static partial void OnModel(this C_Control_ActionsDTO dto, ControlActions model);
  34.  
  35. /// <summary>
  36. /// Converts this instance of <see cref="C_Control_ActionsDTO"/> to an instance of <see cref="ControlActions"/>.
  37. /// </summary>
  38. /// <param name="dto"><see cref="C_Control_ActionsDTO"/> to convert.</param>
  39. public static ControlActions ToModel(this C_Control_ActionsDTO dto)
  40. {
  41. if (dto == null) return null;
  42.  
  43. var cache = ClientEFCache.GetInstance();
  44. var model = cache.GetItem<ControlActions>(dto.ID_Control_Actions);
  45.  
  46. if (model != null)
  47. return model;
  48.  
  49. model = new ControlActions();
  50.  
  51. model.Id = dto.ID_Control_Actions;
  52. model.Name = dto.Control_Name;
  53. model.ActionDelete = dto.Action_Delete;
  54. model.ActionExecute = dto.Action_Execute;
  55. model.ActionWrite = dto.Action_Write;
  56. model.Status = dto.Status;
  57. model.DateModified = dto.Datum_azur;
  58. model.UserModified = dto.User_azur;
  59.  
  60. cache.Add(model);
  61.  
  62. dto.OnModel(model);
  63.  
  64. return model;
  65. }
  66.  
  67. /// <summary>
  68. /// Converts this instance of <see cref="ControlActions"/> to an instance of <see cref="C_Control_ActionsDTO"/>.
  69. /// </summary>
  70. /// <param name="model"><see cref="ControlActions"/> to convert.</param>
  71. public static C_Control_ActionsDTO ToDTO(this ControlActions model)
  72. {
  73. if (model == null) return null;
  74.  
  75. var dto = new C_Control_ActionsDTO();
  76.  
  77. dto.ID_Control_Actions = model.Id ?? default(int);
  78. dto.Control_Name = model.Name;
  79. dto.ID_Activity = model.Activity?.Id ?? default(int);
  80. dto.Action_Delete = model.ActionDelete ?? default (bool);
  81. dto.Action_Execute = model.ActionExecute ?? default(bool);
  82. dto.Action_Write = model.ActionWrite ?? default (bool);
  83. dto.Status = model.Status ?? default (bool);
  84. dto.Datum_azur = model.DateModified ?? default(DateTime);
  85. dto.User_azur = model.UserModified;
  86.  
  87. model.OnDTO(dto);
  88.  
  89. return dto;
  90. }
  91.  
  92. /// <summary>
  93. /// Converts each instance of <see cref="C_Control_ActionsDTO"/> to an instance of <see cref="ControlActions"/>.
  94. /// </summary>
  95. /// <param name="dtos"></param>
  96. /// <returns></returns>
  97. public static List<ControlActions> ToModels(this IEnumerable<C_Control_ActionsDTO> dtos)
  98. {
  99. if (dtos == null) return null;
  100.  
  101. return dtos.Select(e => e.ToModel()).ToList();
  102. }
  103.  
  104. /// <summary>
  105. /// Converts each instance of <see cref="ControlActions"/> to an instance of <see cref="C_Control_ActionsDTO"/>.
  106. /// </summary>
  107. /// <param name="models"></param>
  108. /// <returns></returns>
  109. public static List<C_Control_ActionsDTO> ToDTOs(this IEnumerable<ControlActions> models)
  110. {
  111. if (models == null) return null;
  112.  
  113. return models.Select(e => e.ToDTO()).ToList();
  114. }
  115. }
  116.  
  117. partial class ControlActionsAssembler
  118. {
  119. static partial void OnModel(this C_Control_ActionsDTO dto, ControlActions model)
  120. {
  121. model.Activity = dto.ID_Activity.To<Classification>();
  122. }
  123. }
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement