Base solution for your next web application

Activities of "jonas452"

Hi,

I've tried to upgrade to 4.1 with mixed succes. After digging around i discovered that the latest version of EFCore does not support TPH(Table per heneritance). Wich is a problem for me cause i use that quite often in my database design.

So I'm thinking why not just roll back to EF6. But how do i best tackle that? Let's say i download a blank ASPNet Zero solution V4.1.

How would you guys change the EntityFrameworkCore project to EF6?

Thx for you advice.

Question

Hi,

I'm quite the novice regarding angular and typescript so i am sorry for asking such a basic and easy question. However i can't seem to figure this one out.

In a plane modal i want to use the metronic ui datepicker. i've copied this from the metronic example page to my modal.

<div class="input-group date" data-provide="datepicker">
    <input type="text" class="form-control">
    <div class="input-group-addon">
        <span class="glyphicon glyphicon-th"></span>
    </div>
</div>

however it remains a basic text field.

what am i forgetting? Can you point me in the right direction? Thx.

this is my create-employee-modal.component.ts class and html page

import { Component, Injector, OnInit } from '@angular/core';
import { AppComponentBase } from '@shared/common/app-component-base';
import { appModuleAnimation } from '@shared/animations/routerTransition';
import { PersonServiceProxy, EmployeeDto, ListResultDtoOfEmployeeDto } from '@shared/service-proxies/service-proxies';

@Component({
    templateUrl: './employeepanel.component.html',
    animations: [appModuleAnimation()]
})
export class EmployeePanelComponent extends AppComponentBase implements OnInit {

    employees: EmployeeDto[] = [];
    filter: string = '';

    constructor(
        injector: Injector,        
        private _personService: PersonServiceProxy
    ) {
        super(injector);
    }

        ngOnInit(): void {
        this.getEmployee();
    }

    getEmployee(): void {
        this._personService.getEmployees(this.filter).subscribe((result) => {
            this.employees = result.items;
        });
    }

}
<div bsModal #modal="bs-modal" (onShown)="onShown()" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="modal" aria-hidden="true" [config]="{backdrop: 'static'}">
    <div class="modal-dialog">
        <div class="modal-content">
            <form *ngIf="active" #employeeForm="ngForm" novalidate (ngSubmit)="save()">
                <div class="modal-header">
                    <button type="button" class="close" (click)="close()" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title">
                        <span>{{l("CreateNewEmployee")}}</span>
                    </h4>
                </div>
                <div class="modal-body">
                    
                    <div class="form-group form-md-line-input form-md-floating-label no-hint">
                        <input #nameInput class="form-control" type="text" name="name" [(ngModel)]="employee.name" required maxlength="32">
                        <label>{{l("Name")}}</label>
                    </div>

                    <div class="form-group form-md-line-input form-md-floating-label no-hint">
                        <input class="form-control" type="text" name="firstName" [(ngModel)]="employee.firstName" required maxlength="32">
                        <label>{{l("Surname")}}</label>
                    </div>                    

                    <div class="form-group form-md-line-input form-md-floating-label no-hint">
                        <input class="form-control" type="email" name="email" [(ngModel)]="employee.email" required maxlength="255" pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,})+$">
                        <label>{{l("EmailAddress")}}</label>
                    </div>

                    <div class="form-group form-md-line-input form-md-floating-label no-hint">
                        <input class="form-control" type="text" name="phoneNr" [(ngModel)]="employee.phoneNr" >
                        <label>{{l("PhoneNr")}}</label>
                    </div> 

<div class="input-group date" data-provide="datepicker">
    <input type="text" class="form-control">
    <div class="input-group-addon">
        <span class="glyphicon glyphicon-th"></span>
    </div>
</div>
                    <div class="form-group form-md-line-input form-md-floating-label no-hint">                        
                        <input class="form-control"
                                type="date" name="dateOfBirth" [(ngModel)]="employee.dateOfBirth" >
                        
                    </div>                                       

                </div>
                <div class="modal-footer">
                    <button [disabled]="saving" type="button" class="btn btn-default" (click)="close()">{{l("Cancel")}}</button>
                    <button type="submit" class="btn btn-primary blue" [disabled]="!employeeForm.form.valid" [buttonBusy]="saving" [busyText]="l('SavingWithThreeDot')"><i class="fa fa-save"></i> 
                    <span>{{l("Save")}}</span></button>
                </div>
            </form>
        </div>
    </div>
</div>
Question

Hi,

I noticed that we have now a new node called encryptedAccessToken.
{ "result": { "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6I...................3yS-RmskAfvAmmbPkvQ6Oc", "encryptedAccessToken": "HIINu1cszB7Ow78yl1ysFrluu7uhEg0.....pQvj5MXUQFZRqvQ==", "expireInSeconds": 86400, "shouldResetPassword": false, "passwordResetCode": null, "userId": 0, "requiresTwoFactorVerification": false, "twoFactorAuthProviders": null, "twoFactorRememberClientToken": null }, "targetUrl": null, "success": true, "error": null, "unAuthorizedRequest": false, "__abp": true }

However i can't seem to find any documentation on it. All i need now is the accessToken. Will that change?

thx Jonas.

Hi,

I've got the angular 2 project up and running. Now for testing i would like to use de web api side directly. When i use the authenticate method everything goes fine.

When i check the cookies i can see token being stored.

But when i run any kind of method i receive this response

What am i forgetting?

I also have tried loggin in with the angular client and then using the web api. The result is the same. The client itself works just fine.

Hi,

I'm testing your new solution Angular 2 and .net core. I managed to get it up and running. However i've noticed there is no front end application, by that i mean like those of your other solutions. You call it a landing page for people that ar not logged in. (not login page).

Is it gone, will it be added in the future or am i missing something?

Thx, Jonas

Hi,

I'm running against a bug// error in my code i can't figure out.

I have two classes related to each other. Person and User(aspnetmodulezero class user) User is named PUserAccount in the class Person

public class Person : FullAuditedEntity,IMustHaveTenant
    {
        public const int MaxNameLength = 32;
        public const int MaxFirstnameLength = 32;
        public const int MaxEmailAddressLength = 255;

        public virtual int TenantId { get; set; }
        [Required]
        [MaxLength(MaxNameLength)]
        public virtual string Name { get; set; }
        [Required]
        [MaxLength(MaxFirstnameLength)]
        public virtual string FirstName { get; set; }
        public virtual string PhoneNr { get; set; }
        public virtual User **PUserAccount**{ get; set; }
        [Required]  
        [MaxLength(MaxEmailAddressLength)]      
        public virtual string Email { get; set; }

        public Person()
        {

        }       
    }

In a certain point in my application i let the admin user link a person to a User. A person can exist without a user. To achieve this i have created a domain service.

public class PersonManager : EmployeePlannerSPADomainServiceBase, IPersonManager
    {
        private readonly IRepository<Person> _personRepository;
        private readonly UserManager _userManager;
        private readonly RoleManager _roleManager;

        public PersonManager(IRepository<Person> personRepository, 
                             UserManager userManager,
                             RoleManager roleManager)
        {
            _personRepository = personRepository;
            _userManager = userManager;
            _roleManager = roleManager;
        }

        public Person GetById(int id)
        {
            return _personRepository.GetAll().Where(p => p.Id == id).FirstOrDefault();
        }

        public async Task CreateAsync(Person pers)
        {
            await _personRepository.InsertAsync(pers);
        }

        public async Task<User> CreateNewUserFromPersonAsync(Person p)
        {
            //Get standard role - Tenant id should get injected in this manager
            List<Role> roles = _roleManager.Roles.Where(r =>r.Name == StaticRoleNames.Tenants.User).ToList();
            if (roles.Count == 1)
            {
                User newU = new User()
                {
                    UserName = p.Email,
                    Name = p.Name,
                    Surname = p.FirstName,
                    EmailAddress = p.Email,                    
                    IsEmailConfirmed = false,
                    ShouldChangePasswordOnNextLogin = true,
                    IsActive = false
                };
                await _userManager.CreateAsync(newU, "123qwe");                

                await UpdateAsync(p);

                return p.PUserAccount = newU;
            }
            else
            {
                throw new ApplicationException("No suitable standard role found for new user ");
            }            
        }

        public async Task DeleteByIdAsync(int Id)
        {            
            await _personRepository.DeleteAsync(Id);
        }

        public async Task LinkPersonToUserAsync(Person p, User u)
        {
            //Check if user has been linked before
            var lPers = _personRepository.GetAll().Where(
                    per => per.PUserAccount != null &&
                           per.PUserAccount.Id == u.Id                    
                ).ToList();
            
            if (lPers.IsNullOrEmpty())
            {
                p.PUserAccount = u;
                await UpdateAsync(p);
            }
            else
            {
                throw new ApplicationException("That user account is already linked to an other person");
            }            
        }

        public async Task UpdateAsync(Person pers)
        {
            await _personRepository.UpdateAsync(pers);
        }
    }

In my domain service you see a method LinkPersonToUserAsync. When executed i receive a exception on following line

per => per.PUserAccount != null &&
                           per.PUserAccount.Id == u.Id

The error : ERROR 2016-12-01 21:34:07,433 [6 ] nHandling.AbpApiExceptionFilterAttribute - An error occurred while preparing the command definition. See the inner exception for details. System.Data.Entity.Core.EntityCommandCompilationException: An error occurred while preparing the command definition. See the inner exception for details. ---> System.ApplicationException: FK Constriant not found for association 'EmployeePlannerSPA.EntityFramework.Person_PUserAccount' - must directly specify foreign keys on model to be able to apply this filter at EntityFramework.DynamicFilters.DynamicFilterQueryVisitorCSpace.Visit(DbPropertyExpression expression) at System.Data.Entity.Core.Common.CommandTrees.DbPropertyExpression.Accept[TResultType](DbExpressionVisitor1 visitor) at System.Data.Entity.Core.Common.CommandTrees.DefaultExpressionVisitor.VisitExpression(DbExpression expression) at System.Data.Entity.Core.Common.CommandTrees.DefaultExpressionVisitor.Visit(DbPropertyExpression expression) at EntityFramework.DynamicFilters.DynamicFilterQueryVisitorCSpace.Visit(DbPropertyExpression expression) at System.Data.Entity.Core.Common.CommandTrees.DbPropertyExpression.Accept[TResultType](DbExpressionVisitor1 visitor) at System.Data.Entity.Core.Common.CommandTrees.DefaultExpressionVisitor.VisitExpression(DbExpression expression) at System.Data.Entity.Core.Common.CommandTrees.DefaultExpressionVisitor.VisitBinary(DbBinaryExpression expression, Func3 callback) at System.Data.Entity.Core.Common.CommandTrees.DefaultExpressionVisitor.Visit(DbComparisonExpression expression) at System.Data.Entity.Core.Common.CommandTrees.DbComparisonExpression.Accept[TResultType](DbExpressionVisitor1 visitor) at System.Data.Entity.Core.Common.CommandTrees.DefaultExpressionVisitor.VisitExpression(DbExpression expression) at System.Data.Entity.Core.Common.CommandTrees.DefaultExpressionVisitor.Visit(DbFilterExpression expression) at System.Data.Entity.Core.Common.CommandTrees.DbFilterExpression.Accept[TResultType](DbExpressionVisitor1 visitor) at System.Data.Entity.Core.Common.CommandTrees.DefaultExpressionVisitor.VisitExpression(DbExpression expression) at System.Data.Entity.Core.Common.CommandTrees.DefaultExpressionVisitor.VisitExpressionBinding(DbExpressionBinding binding) at System.Data.Entity.Core.Common.CommandTrees.DefaultExpressionVisitor.VisitExpressionBindingEnterScope(DbExpressionBinding binding) at System.Data.Entity.Core.Common.CommandTrees.DefaultExpressionVisitor.Visit(DbProjectExpression expression) at System.Data.Entity.Core.Common.CommandTrees.DbProjectExpression.Accept[TResultType](DbExpressionVisitor1 visitor) at EntityFramework.DynamicFilters.DynamicFilterInterceptor.TreeCreated(DbCommandTreeInterceptionContext interceptionContext)

I'm not an expert on Entity framework but any help to filter on a foreign key for independent association would be appreciated. I really don't want to create a mapping with fluent mapi and define my own constraint(or create navigation properties in my poco). I have checked the database and the constraint has been autmaticaly created by EF

Currently i'm on version aspnetzero : v1.13.0.0

Thanks, Jonas

Hi,

I have decided i will develop my aspnetzero application with angular. Now looking at the current road map i see that implementing angular2 is on the list.

I was wondering when the next version of aspnetzero with angular2 will be released. If the release date is near the end of 2017 then i'll focus my efforts on angular1 and find a way to upgrade to angular2 (i heard it wont be easy) But if the release date is in the near future i may be able to delay my develoment and start on the front end when it's released. I prefer the second option.

So a rough eta would be much appreciated.

Thx! Jonas

Showing 1 to 7 of 7 entries