public async Task <User> CreateExternalUser(string login) { var user = new User(); user.Id = Guid.NewGuid(); user.Login = login.ToLower(); user.ActivationCode = Guid.NewGuid(); user.Password = "******"; user.Type = LoginType.EXTERNAL; user.IsActive = true; var lstRole = await RoleRepository.GetWhereAsync(r => r.Name.ToLower().Equals("external")); if (!lstRole.Any()) { throw new Exception("Cannot find role external"); } await UserRoleRepository.AddAsync(new UserRole() { User = user, RoleId = lstRole.First().Id }); await this.Repository.SaveAsync(); return(user); }
public async Task <Guid> CreateDonorPF(DonorPFCreateDto donorPFDto) { User user = new User(Guid.NewGuid(), donorPFDto.Login.ToLower(), donorPFDto.Password.ToSHA512(), LoginType.DONOR_PF, Guid.NewGuid(), true); var donorPF = this.Mapper.Map <DonorPF>(donorPFDto); donorPF.Id = Guid.NewGuid(); donorPF.UserId = user.Id; var lstRole = await RoleRepository.GetWhereAsync(r => r.Name.ToLower().Equals("donor_pf")); if (!lstRole.Any()) { throw new Exception("Cannot find role donor_pf"); } await UserRoleRepository.AddAsync(new UserRole() { User = user, RoleId = lstRole.First().Id }); await this.Repository.AddAsync(donorPF); await this.Repository.SaveAsync(); return(donorPF.Id); }
public async Task <Guid> CreateCharity(CharityCreateDto charityDto) { User user = new User(Guid.NewGuid(), charityDto.Login.ToLower(), charityDto.Password.ToSHA512(), LoginType.CHARITABLE_ENTITY, Guid.NewGuid(), true); var charitable = this.Mapper.Map <CharitableEntity>(charityDto); charitable.Status = ApproverStatus.PENDING; charitable.IsActive = false; charitable.ApproverData = null; charitable.Approver = string.Empty; charitable.Id = Guid.NewGuid(); charitable.UserId = user.Id; var approval = new Approval() { Id = Guid.NewGuid(), CharitableEntityId = charitable.Id, Date = DateTime.UtcNow.ToBrazilianTimeZone(), Message = "AnĂ¡lise Pendente", Status = (int)ApproverStatus.PENDING }; var lstRole = await RoleRepository.GetWhereAsync(r => r.Name.ToLower().Equals("charitable_entity")); if (!lstRole.Any()) { throw new Exception("Cannot find role charitable_entity"); } await UserRoleRepository.AddAsync(new UserRole() { User = user, RoleId = lstRole.First().Id }); await this.Repository.AddAsync(charitable); await ApprovalRepository.AddAsync(approval); await this.Repository.SaveAsync(); return(charitable.Id); }