public AccountController(IS1Context appContext, IAppIdentityContext identityContext) : base(appContext, identityContext) { }
public async Task <IHttpActionResult> Register(RegisterRequest model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //using (TransactionScope scope = new TransactionScope()) { IS1Context db = AppCore.IoC.Container.Resolve <IS1Context>(); try { string roleId = _identityContext.GetRoleIdByCode("CM"); AppTenant tenant = new AppTenant(); tenant.Name = model.PropertyName; var user = new AppUser() { UserName = model.Email, Email = model.Email }; user.AppTenantUsers.Add(new AppTenantUser() { AppRoleID = roleId, AppTenant = tenant }); IdentityResult result = await UserManager.CreateAsync(user, model.Password); if (!result.Succeeded) { //scope.Dispose(); return(GetErrorResult(result)); } var region = (_appContext as IS1Context).Regions.Single(x => x.Code == "BC"); //temp var tenantParty = new Party() { AppTenantID = tenant.ID, Name = model.PropertyName, PartyType = "C" }; var tentantEntity = new AccountingEntity() { AppTenantID = tenant.ID, Party = tenantParty, Region = region }; db.AccountingEntities.Add(tentantEntity); await db.SaveChangesAsync(); //scope.Complete(); } catch (Exception ex) { //scope.Dispose(); throw ex; } } return(Ok()); }
public SearchController(IS1Context appContext, IAppIdentityContext identityContext, ISearchService searchService) : base(appContext, identityContext, searchService) { }