fix edit profile
This commit is contained in:
parent
5565bb7070
commit
912cbdbecf
@ -1,22 +1,27 @@
|
||||
using Abp.Authorization;
|
||||
using System.Linq;
|
||||
using Abp.Authorization;
|
||||
using Abp.Domain.Repositories;
|
||||
using Abp.Domain.Uow;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Threading.Tasks;
|
||||
using SystemKonkursow.Authorization.Users;
|
||||
using SystemKonkursow.UserProfile.Dto;
|
||||
using Abp.UI;
|
||||
|
||||
namespace SystemKonkursow.UserProfile
|
||||
{
|
||||
public class UserProfileAppService : SystemKonkursowAppServiceBase
|
||||
{
|
||||
private readonly UserManager _userManager;
|
||||
private readonly IRepository<User, long> _userRepository;
|
||||
private readonly IRepository<Domain.Participant, int> _participantRepository;
|
||||
|
||||
public UserProfileAppService(UserManager userManager,
|
||||
IRepository<User, long> userRepository,
|
||||
IRepository<Domain.Participant, int> participantRepository)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_userRepository = userRepository;
|
||||
_participantRepository = participantRepository;
|
||||
}
|
||||
|
||||
@ -50,6 +55,25 @@ namespace SystemKonkursow.UserProfile
|
||||
{
|
||||
var user = await _userManager.GetUserByIdAsync(userProfile.Id);
|
||||
|
||||
var checkUserEmail = _userRepository.GetAll().Where(t => t.EmailAddress == userProfile.EmailAddress && t.Id != user.Id).FirstOrDefault();
|
||||
|
||||
var checkUserName = _userRepository.GetAll().Where(t => t.UserName == userProfile.UserName && t.Id != user.Id).FirstOrDefault();
|
||||
|
||||
if (null != checkUserEmail && null != checkUserName)
|
||||
{
|
||||
throw new UserFriendlyException(L("ProfileFailed"), string.Format("Użytkownik o adresie email: {0} i nazwie użytkownika: {1} już istnieje", userProfile.EmailAddress, userProfile.UserName));
|
||||
}
|
||||
|
||||
if (null != checkUserEmail)
|
||||
{
|
||||
throw new UserFriendlyException(L("ProfileFailed"), string.Format("Użytkownik o adresie email: {0} już istnieje", userProfile.EmailAddress));
|
||||
}
|
||||
|
||||
if (null != checkUserName)
|
||||
{
|
||||
throw new UserFriendlyException(L("ProfileFailed"), string.Format("Użytkownik o nazwie użytkownika: {0} już istnieje", userProfile.UserName));
|
||||
}
|
||||
|
||||
ObjectMapper.Map(userProfile, user);
|
||||
user.SetNormalizedNames();
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
<text name="CanBeEmptyToLoginAsHost" value="Can be empty to login as host." />
|
||||
<text name="Register" value="Register" />
|
||||
<text name="RegisterFailed" value="Błąd rejestracji!" />
|
||||
<text name="ProfileFailed" value="Błąd aktualizacji profilu!" />
|
||||
<text name="OrLoginWith" value="Or login with" />
|
||||
<text name="WaitingForActivationMessage" value="Your account is waiting to be activated by system admin." />
|
||||
<text name="TenantSelection" value="Tenant Selection" />
|
||||
|
Loading…
Reference in New Issue
Block a user