예제 #1
0
 public async Task <int> CreateUserWithOrganisation(OrgUserFullVM obj)
 {
     try
     {
         return(await StdRepo.ExcuteStoredProcedureToSave <OrgUserFullVM>(GlobalSPNames.AddOrganizationSPName, obj));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #2
0
        public async Task <IHttpActionResult> CreateBuyerWithOrganisation(OrgUserFullVM userModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            IdentityResult result = await _repo.CreateBuyerWithOrganisation(userModel);

            IHttpActionResult errorResult = GetErrorResult(result);

            if (errorResult != null)
            {
                return(errorResult);
            }

            return(Ok());
        }
예제 #3
0
        /// <summary>
        /// This will create a buyer and the organisation at the same time.
        /// </summary>
        /// <param name="userModel"></param>
        /// <returns></returns>
        public async Task <IdentityResult> CreateBuyerWithOrganisation(OrgUserFullVM userModel)
        {
            IdentityUser user = new IdentityUser
            {
                UserName = userModel.UserDet.UserName,
            };
            //Saving the user to the ASP.NET user tables
            var result = await _userManager.CreateAsync(user, userModel.UserDet.Password);

            //Set the user id to the ASP.net User id
            userModel.UserDet.UserId           = user.Id;
            userModel.OrganisazionDet.IsSeller = false;
            //If above was successfull then we will add the organization and our detail user accounts
            if (result.Succeeded)
            {
                //Manually set the org type
                userModel.OrganisazionDet.IsSeller = false;
                CorparateRepository corprepo = new CorparateRepository();
                await corprepo.CreateUserWithOrganisation(userModel);
            }

            return(result);
        }