asp.net mvc 5 - Converting a application user Player to a user Developer, where developer extends Player -



asp.net mvc 5 - Converting a application user Player to a user Developer, where developer extends Player -

i have class player - extending applicationuser - , developer - extending player -. want users able become developers whenever wish, have somehow convert object of class player 1 of class developer @ point, i'm confused how this.

public class player : applicationuser { public virtual icollection<playing> playing { get; set; } } public class developer : player { public datetime dateconverted { get; set; } public virtual icollection<game> games { get; set; } }

i though retrieve object player, remove database, instantiate object of type developer, copying info , save it. this:

public virtual async task<developer> convert(player player) { var developer = new developer { id = player.id, datebirth = player.datebirth, datecreated = player.datecreated, dateupdated = player.dateupdated, email = player.email, emailconfirmed = player.emailconfirmed, username = player.username }; db.players.remove(player); db.developers.add(developer); }

the problem is: when delete entry of player, relationships lost it.

is there better/easier way this? far know, have alter discriminator field in applicationuser table "developer".

well, haven't been able prepare properly, workaround i've found not separate player , developer 2 classes, instead maintain both classes' properties in player. difference given property datecoverted, represents date in given player converted developer.

something this:

public class player : applicationuser { public virtual icollection<playing> playing { get; set; } public datetime? dateconverted { get; set; } public virtual icollection<game> games { get; set; } } public class playerservice : service<player> { public virtual async task<player> convert(string id) { var developer = await db.players.findasync(id); developer.dateconverted = datetime.now; await update(developer); homecoming developer; } }

asp.net-mvc-5 entity-framework-6 identity

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -