Example #1
0
        public async Task <CreatedUserModel> NewAccountAsync(AddUpModel model, string uri)
        {
            var email = _context.Company.Where(a => a.EmailAddress == model.emailAddress).SingleOrDefault();

            if (email == null)
            {
                var user  = _mapper.Map <ApplicationUser>(model);
                var asp   = _mapper.Map <AspNetUser>(user);
                var compa = _mapper.Map <Company>(model);
                compa.CompanyCode = IdBuilder();
                _context.Company.Add(compa);
                _context.SaveChanges();

                asp.CompanyId = compa.CompanyId;
                //asp.DateCreated = DateTime.UtcNow;
                //asp.CategoryId = model.CategoryId;
                //asp.PositionId = model.PositionId;
                //asp.JobTypeId = model.JobTypeId;

                _context.AspNetUser.Add(asp);
                _context.SaveChanges();

                // //if (!roleResult.Succeeded || !claimResult.Succeeded)
                // //{

                // //    await _context.ErrorLogs.AddAsync(new ErrorLogs
                // //    {
                // //        ErrorMessage = string.Join(" xx | xx ", "gffd")
                // //    });

                // //    return null;
                // //}
                // ////Update UserId

                var mapper = _mapper.Map <CreatedUserModel>(user);
                //mapper.Token = await GenerateEmailConfirmation(model.emailAddress, "", uri);
                //// mapper.GUID = _guidMethod.GetGUIByUserId(user.Id);

                // mapper.Claim = new ClaimType
                // {
                //     Value = "True",
                //     Type = Claim
                // };

                // mapper.Role = Role;

                return(mapper);
            }

            return(null);
        }
        public async Task <IActionResult> NewUserAsync([FromBody] AddUpModel model)
        {
            var uri  = HttpContext.Request.Host.Value;
            var user = await _user.NewAccountAsync(model, "");

            if (user == null)
            {
                return(BadRequest(new
                {
                    error = _badRequest.ShowError(
                        _badRequest.ErrAccountDuplication
                        )
                }));
            }
            //Send Verification Email to User
            //try
            //{
            //    var code = await _user.GenerateEmailConfirmation(model.Email, "", "");
            //}
            //catch (System.Exception ex)
            //{
            //    return BadRequest(new
            //    {
            //        error = ex.Message,
            //        errorstack = ex.StackTrace
            //    });
            //}

            //return CreatedAtAction("Index", "Home", new
            //{
            //    username = user.Username
            //}, new
            //{
            //    data = user,
            //    link = new
            //    {
            //        self = Url.Action("Index", "Home", new
            //        {
            //            username = user.Username
            //        }, Request.Scheme)
            //    }
            //});

            return(Ok());
        }
 public async Task <CreatedUserModel> AddNewUser(AddUpModel model)
 {
     return(null);
 }