Skip to content

Commit ed10e74

Browse files
committed
Make MVC application running again for new user and tenant service.
1 parent 0dc9427 commit ed10e74

File tree

11 files changed

+32
-23
lines changed

11 files changed

+32
-23
lines changed

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/Users/Dto/CreateUserDto.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Abp.Auditing;
33
using Abp.Authorization.Users;
44
using Abp.AutoMapper;
5-
65
using AbpCompanyName.AbpProjectName.Authorization.Users;
76

87
namespace AbpCompanyName.AbpProjectName.Users.Dto
@@ -35,10 +34,5 @@ public class CreateUserDto
3534
[StringLength(AbpUserBase.MaxPlainPasswordLength)]
3635
[DisableAuditing]
3736
public string Password { get; set; }
38-
39-
[Required]
40-
[StringLength(AbpUserBase.MaxPlainPasswordLength)]
41-
[DisableAuditing]
42-
public string ConfirmPassword { get; set; }
4337
}
4438
}

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/Users/Dto/UserDto.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
using System;
22
using System.ComponentModel.DataAnnotations;
3-
43
using Abp.Application.Services.Dto;
54
using Abp.Authorization.Users;
65
using Abp.AutoMapper;
7-
86
using AbpCompanyName.AbpProjectName.Authorization.Users;
97

108
namespace AbpCompanyName.AbpProjectName.Users.Dto
@@ -17,11 +15,11 @@ public class UserDto : EntityDto<long>
1715
public string UserName { get; set; }
1816

1917
[Required]
20-
[StringLength(User.MaxNameLength)]
18+
[StringLength(AbpUserBase.MaxNameLength)]
2119
public string Name { get; set; }
2220

2321
[Required]
24-
[StringLength(User.MaxSurnameLength)]
22+
[StringLength(AbpUserBase.MaxSurnameLength)]
2523
public string Surname { get; set; }
2624

2725
[Required]
@@ -30,8 +28,11 @@ public class UserDto : EntityDto<long>
3028
public string EmailAddress { get; set; }
3129

3230
public bool IsActive { get; set; }
31+
3332
public string FullName { get; set; }
33+
3434
public DateTime? LastLoginTime { get; set; }
35+
3536
public DateTime CreationTime { get; set; }
3637

3738
public string[] Roles { get; set; }

aspnet-core/src/AbpCompanyName.AbpProjectName.Application/Users/UserAppService.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using AbpCompanyName.AbpProjectName.Users.Dto;
99
using Microsoft.AspNetCore.Identity;
1010
using System.Linq;
11+
using Abp.Collections.Extensions;
1112
using Microsoft.EntityFrameworkCore;
1213
using Abp.IdentityFramework;
1314
using AbpCompanyName.AbpProjectName.Authorization.Roles;
@@ -47,7 +48,11 @@ public override async Task<UserDto> Create(CreateUserDto input)
4748
user.IsEmailConfirmed = true;
4849

4950
CheckErrors(await _userManager.CreateAsync(user));
50-
CheckErrors(await _userManager.SetRoles(user, input.Roles));
51+
52+
if (input.Roles != null)
53+
{
54+
CheckErrors(await _userManager.SetRoles(user, input.Roles));
55+
}
5156

5257
CurrentUnitOfWork.SaveChanges();
5358

@@ -63,8 +68,12 @@ public override async Task<UserDto> Update(UserDto input)
6368
MapToEntity(input, user);
6469

6570
CheckErrors(await _userManager.UpdateAsync(user));
66-
CheckErrors(await _userManager.SetRoles(user, input.Roles));
67-
71+
72+
if (input.Roles != null)
73+
{
74+
CheckErrors(await _userManager.SetRoles(user, input.Roles));
75+
}
76+
6877
return await Get(input);
6978
}
7079

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/Controllers/TenantsController.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Abp.Application.Services.Dto;
1+
using System.Threading.Tasks;
2+
using Abp.Application.Services.Dto;
23
using Abp.AspNetCore.Mvc.Authorization;
34
using AbpCompanyName.AbpProjectName.Authorization;
45
using AbpCompanyName.AbpProjectName.Controllers;
@@ -17,9 +18,9 @@ public TenantsController(ITenantAppService tenantAppService)
1718
_tenantAppService = tenantAppService;
1819
}
1920

20-
public ActionResult Index()
21+
public async Task<ActionResult> Index()
2122
{
22-
var output = _tenantAppService.GetAll(new PagedResultRequestDto());
23+
var output = await _tenantAppService.GetAll(new PagedResultRequestDto { MaxResultCount = int.MaxValue }); //Paging not implemented yet
2324
return View(output);
2425
}
2526
}

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/Controllers/UsersController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public UsersController(IUserAppService userAppService)
2020

2121
public async Task<ActionResult> Index()
2222
{
23-
var output = await _userAppService.GetAll(new PagedResultRequestDto());
23+
var output = await _userAppService.GetAll(new PagedResultRequestDto { MaxResultCount = int.MaxValue }); //Paging not implemented yet
2424
return View(output);
2525
}
2626
}

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/Views/Tenants/Index.cshtml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@using Abp.MultiTenancy
33
@using AbpCompanyName.AbpProjectName.MultiTenancy
44
@using AbpCompanyName.AbpProjectName.Web.Startup
5-
@model Abp.Application.Services.Dto.ListResultDto<AbpCompanyName.AbpProjectName.MultiTenancy.Dto.TenantDto>
5+
@model Abp.Application.Services.Dto.PagedResultDto<AbpCompanyName.AbpProjectName.MultiTenancy.Dto.TenantDto>
66
@{
77
ViewBag.CurrentPageName = PageNames.Tenants; //The menu item will be active for this page.
88
}
@@ -96,6 +96,10 @@
9696
<label class="form-label">@L("AdminEmailAddress")</label>
9797
</div>
9898
</div>
99+
<div class="checkbox">
100+
<input type="checkbox" name="IsActive" value="true" id="CreateTenantIsActive" class="filled-in" checked />
101+
<label for="CreateTenantIsActive">@L("IsActive")</label>
102+
</div>
99103
<p>@L("DefaultPasswordIs", AbpCompanyName.AbpProjectName.Authorization.Users.User.DefaultPassword)</p>
100104
</div>
101105
<div class="modal-footer">

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/Views/Users/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@using Abp.Authorization.Users
22
@using AbpCompanyName.AbpProjectName.Web.Startup
3-
@model Abp.Application.Services.Dto.ListResultDto<AbpCompanyName.AbpProjectName.Users.Dto.UserDto>
3+
@model Abp.Application.Services.Dto.PagedResultDto<AbpCompanyName.AbpProjectName.Users.Dto.UserDto>
44
@{
55
ViewBag.CurrentPageName = PageNames.Users; //The menu item will be active for this page.
66
}

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/wwwroot/view-resources/Views/Tenants/Index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
var tenant = _$form.serializeFormToObject(); //serializeFormToObject is defined in main.js
1818

1919
abp.ui.setBusy(_$modal);
20-
_tenantService.createTenant(tenant).done(function () {
20+
_tenantService.create(tenant).done(function () {
2121
_$modal.modal('hide');
2222
location.reload(true); //reload page to see new tenant!
2323
}).always(function() {

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/wwwroot/view-resources/Views/Tenants/Index.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/wwwroot/view-resources/Views/Users/Index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
var user = _$form.serializeFormToObject(); //serializeFormToObject is defined in main.js
1818

1919
abp.ui.setBusy(_$modal);
20-
_userService.createUser(user).done(function () {
20+
_userService.create(user).done(function () {
2121
_$modal.modal('hide');
2222
location.reload(true); //reload page to see new user!
2323
}).always(function () {

0 commit comments

Comments
 (0)