public async Task <IHttpActionResult> PostIdentityUserProfile(IdentityUserProfileVm vm)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = Task.Factory.StartNew(() =>
            {
                IUnitOfWork uow = new UnitOfWorkImp(new IRepositoryConnection[] { IdentityUserProfileRepository });
                var bo          = (BOIdentityUserProfile)vm.BOIdentityUserProfile(IdentityUserProfileRepository);
                uow.Create(bo);

                string err;
                if (!uow.Commit(out err))
                {
                    var resp = new HttpResponseMessage(HttpStatusCode.BadRequest)
                    {
                        Content = new StringContent(err)
                    };
                    throw new HttpResponseException(resp);
                }
                vm = new IdentityUserProfileVm(bo);
                return(true);
            });
            await result;

            return(CreatedAtRoute("DefaultApi", new { id = vm.UserId }, vm));
        }
        public async Task <IHttpActionResult> PutIdentityUserProfile(Int32 id, IdentityUserProfileVm vm)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != vm.UserId)
            {
                return(BadRequest());
            }

            var result = Task.Factory.StartNew(() => {
                IUnitOfWork uow = new UnitOfWorkImp(new IRepositoryConnection[] { IdentityUserProfileRepository });
                var bo          = (BOIdentityUserProfile)vm.BOIdentityUserProfile(IdentityUserProfileRepository);
                uow.Update(bo);

                string err;
                if (!uow.Commit(out err))
                {
                    var resp = new HttpResponseMessage(HttpStatusCode.BadRequest)
                    {
                        Content = new StringContent(err)
                    };
                    throw new HttpResponseException(resp);
                }
                return(true);
            });
            await result;

            if (!result.Result)
            {
                return(NotFound());
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }