Advertisement
Guest User

Untitled

a guest
Oct 7th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.12 KB | None | 0 0
  1. public ClientsController(IClientAppService clientService)
  2. {
  3. _clientService = clientService;
  4. }
  5.  
  6. public async Task<ViewResult> Index(GetAllClientsInput input)
  7. {
  8. var output = await _clientService.GetAll(input);
  9. var model = new Web.Models.Clients.IndexViewModel(output.Items);
  10. return View("Index", model);
  11.  
  12. }
  13.  
  14. public async Task Create(CreateClientInput input)
  15. {
  16. await _clientService.Create(input);
  17. }
  18.  
  19. public async Task Delete(CreateClientInput input)
  20. {
  21. await _clientService.Create(input);
  22. }
  23. }`
  24.  
  25. (function() {
  26. $(function() {
  27.  
  28. var _clientService = abp.services.app.client;
  29. var _$modal = $('#ClientCreateModal');
  30. var _$form = _$modal.find('form');
  31.  
  32. _$form.validate();
  33.  
  34. _$form.find('button[type="submit"]').click(function (e) {
  35. e.preventDefault();
  36.  
  37. if (!_$form.valid()) {
  38. return;
  39. }
  40.  
  41. var client = _$form.serializeFormToObject(); //serializeFormToObject is defined in main.js
  42.  
  43. abp.ui.setBusy(_$modal);
  44. _clientService.create(client).done(function () {
  45. _$modal.modal('hide');
  46. location.reload(true); //reload page to see new user!
  47. }).always(function () {
  48. abp.ui.clearBusy(_$modal);
  49. });
  50. });
  51.  
  52. _$modal.on('shown.bs.modal', function () {
  53. _$modal.find('input:not([type=hidden]):first').focus();
  54. });
  55. });
  56. })();
  57.  
  58. @section scripts
  59. {
  60. <environment names="Development">
  61. <script src="~/js/views/clients/Index.js" asp-append-version="true"></script>
  62. </environment>
  63.  
  64. <environment names="Staging,Production">
  65. <script src="~/js/views/clients/Index.min.js" asp-append-version="true"></script>
  66. </environment>
  67. }
  68. <div class="row clearfix">
  69. <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
  70. <div class="card">
  71. <div class="header">
  72. <h2>
  73. @L("Clients")
  74. </h2>
  75. <ul class="header-dropdown m-r--5">
  76. <li class="dropdown">
  77. <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
  78. <i class="material-icons">more_vert</i>
  79. </a>
  80. <ul class="dropdown-menu pull-right">
  81. <li><a href="javascript:void(0);" class=" waves-effect waves-block">Action</a></li>
  82. <li><a href="javascript:void(0);" class=" waves-effect waves-block">Another action</a></li>
  83. <li><a href="javascript:void(0);" class=" waves-effect waves-block">Something else here</a></li>
  84. </ul>
  85. </li>
  86. </ul>
  87. </div>
  88. <div class="body table-responsive">
  89. <table class="table">
  90. <thead>
  91. <tr>
  92. <th>@L("UserName")</th>
  93. <th>@L("FullName")</th>
  94. <th>@L("EmailAddress")</th>
  95. <th>@L("IsActive")</th>
  96. </tr>
  97. </thead>
  98. <tbody>
  99. @foreach (var user in Model.Clients)
  100. {
  101. <tr>
  102. <td>@user.FirstName</td>
  103. <td>@user.LastName</td>
  104. <td>@user.Email</td>
  105. <td>@user.Mobile</td>
  106. </tr>
  107. }
  108. </tbody>
  109. </table>
  110. <button type="button" class="btn btn-primary btn-circle waves-effect waves-circle waves-float pull-right" data-toggle="modal" data-target="#ClientCreateModal">
  111. <i class="material-icons">add</i>
  112. </button>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. <div class="modal fade" id="ClientCreateModal" tabindex="-1" role="dialog" aria-labelledby="ClientCreateModalLabel" data-backdrop="static">
  118. <div class="modal-dialog" role="document">
  119. <div class="modal-content">
  120. <form name="userCreateForm" role="form" novalidate class="form-validation">
  121. <div class="modal-header">
  122. <h4 class="modal-title">
  123. <span>@L("CreateNewClient")</span>
  124. </h4>
  125. </div>
  126. <div class="modal-body">
  127. <div class="form-group form-float">
  128. <div class="form-line">
  129. <input class="form-control" type="text" name="FirstName" required maxlength="@AbpUserBase.MaxUserNameLength" minlength="2">
  130. <label class="form-label">@L("FirstName")</label>
  131. </div>
  132. </div>
  133. <div class="form-group form-float">
  134. <div class="form-line">
  135. <input type="text" name="LastName" class="form-control" required maxlength="@AbpUserBase.MaxNameLength">
  136. <label class="form-label">@L("LastName")</label>
  137. </div>
  138. </div>
  139. <div class="form-group form-float">
  140. <div class="form-line">
  141. <input type="text" name="Mobile" class="form-control" required maxlength="@AbpUserBase.MaxSurnameLength">
  142. <label class="form-label">@L("Mobile")</label>
  143. </div>
  144. </div>
  145. <div class="form-group form-float">
  146. <div class="form-line">
  147. <input type="email" name="Email" class="form-control" required maxlength="@AbpUserBase.MaxEmailAddressLength">
  148. <label class="form-label">@L("Email")</label>
  149. </div>
  150. </div>
  151. </div>
  152. <div class="modal-footer">
  153. <button type="button" class="btn btn-default waves-effect" data-dismiss="modal">@L("Cancel")</button>
  154. <button type="submit" class="btn btn-primary waves-effect">@L("Save")</button>
  155. </div>
  156. </form>
  157. </div>
  158. </div>
  159. </div>
  160.  
  161. [AbpAuthorize(PermissionNames.Pages_Tenants)]
  162. public class ClientAppService : ApplicationService, IClientAppService
  163. {
  164. private readonly IRepository<Client> _clientRepository;
  165.  
  166. public ClientAppService(IRepository<Client> clientRepository)
  167. {
  168. _clientRepository = clientRepository;
  169. }
  170.  
  171. public async Task<ListResultDto<ClientListDto>> GetAll(GetAllClientsInput input)
  172. {
  173. var clients = await _clientRepository
  174. .GetAll().ToListAsync<Client>();
  175.  
  176. return new ListResultDto<ClientListDto>(
  177. ObjectMapper.Map<List<ClientListDto>>(clients));
  178. }
  179.  
  180. public async Task Create(CreateClientInput input)
  181. {
  182. var task = ObjectMapper.Map<Client>(input);
  183. await _clientRepository.InsertAsync(task);
  184. }
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement