Esempio n. 1
0
        public async Task<IHttpActionResult> Register(UserModel userModel)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var result = await _repo.RegisterUser(userModel);

            return Ok();
        }
Esempio n. 2
0
        public async Task<IHttpActionResult> Register(UserModel userModel)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

           // IdentityResult result = await _repo.RegisterUser(userModel);
            var result = await _repo.RegisterUser(userModel);

            //IHttpActionResult errorResult = GetErrorResult(result);

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

            return Ok();
        }
Esempio n. 3
0
          //  public async Task<IdentityResult> RegisterUser(UserModel userModel)
            public async Task<IdentityResult> RegisterUser(UserModel userModel)
            {
                if (userModel.DateOfBirth != null)
                {
                    IdentityUser user = new IdentityUser
                    {
                        UserName = userModel.UserName,
                    };
                    EndUser eu = new EndUser()
                    {
                        Street1 = userModel.Street1,
                        Street2 = userModel.Street2,
                        City = userModel.City,
                        State = userModel.State,
                        Country = userModel.Country,
                        PIN = userModel.PIN,
                        ContactNumber = userModel.ContactNumber,
                        //  DateOfBirth = userModel.DateOfBirth,
                        Email = userModel.UserName,
                        DateOfJoining = DateTime.Now

                    };
                    _ctx.EndUser.Add(eu);
                    _ctx.SaveChanges();

                    //EveryBody = new EveryBody
                    //{
                    //   //ID= 1,
                    //    Email=model.Email
                    //}



                    var result = await _userManager.CreateAsync(user, userModel.Password);
                }

                else
                {
                    var e = userModel.UserName;
                    ProductOwner po = _ctx.ProductOwner.FirstOrDefault(d => d.Email == e);
                    po.Email = userModel.UserName;
                    po.Description = userModel.Description;
                    po.DateOfJoining = DateTime.Now;
                    po.FoundedIn = userModel.FoundedIn;
                    po.Street1 = userModel.Street1;
                    po.Street2 = userModel.Street2;
                    po.City = userModel.City;
                    po.State = userModel.State;
                    po.Country = userModel.Country;
                    po.PIN = userModel.PIN;
                    po.ContactNumber = userModel.ContactNumber;
                    po.TwitterHandler = userModel.TwitterHandler;
                    po.WebsiteURL = userModel.WebsiteURL;
                    po.FacebookPageURL = userModel.FacebookPageURL;
                    _ctx.Entry(po).State = EntityState.Modified;
                    var result1 = _ctx.SaveChanges();

                    IdentityUser user = new IdentityUser
                    {
                        UserName = userModel.UserName
                    };

                    var result = await _userManager.CreateAsync(user, userModel.Password);

                    if (result.Succeeded && result1 > 0)
                    {
                        if (po.EmailConfirmed == false && po.Approval == true)
                        {
                            po.EmailConfirmed = true;
                            _ctx.Entry(po).State = EntityState.Modified;
                            var op1 = _ctx.SaveChanges();
                            user.EmailConfirmed = true;
                            //  var op = UserManager.UpdateAsync(user);
                            _userManager.Update(user);
                        }
                        //else
                        //{
                        //   go to error page
                        //}
                    }

                    return result;
                }
                return null;
            }