public async Task <ActionResult> Register(FormCollection collection)
        {
            var fields  = collection.RemoveUnnecessaryAndEmptyFields().ToFieldValueOrder().RemoveEmptyFields();
            var product = fields.FirstOrDefault(s => s.KeyInt == 12);

            if (product == null)
            {
                return(RedirectToAction("ShowInformation", "Messages", new { code = "-1" })); //product not found
            }
            int productid;

            if (!int.TryParse(product.Value, out productid))
            {
                return(RedirectToAction("ShowInformation", "Messages", new { code = "0" })); //invalid product
            }

            var nuser = await _userAppService.GetUserByMappingField(GlobalVariables.FieldToCreateUser, fields);

            if (!nuser.IdentificationType.HasValue)
            {
                return(RedirectToAction("ShowInformation", "Messages", new { code = "100" })); //invalid Document type
            }

            var user = await _userAppService.FindAsync(nuser.Identification, nuser.IdentificationType.Value, nuser.Identification + ConfigurationManager.AppSettings["Salt"]);

            //re-take Request
            if (user != null)
            {
                nuser           = user;
                nuser.IsNewUser = false;
                var response =
                    _userAppService.GetValidExecutionByUserAndProduct(user.Id, (int)Session["Product"]);

                if (response != 0)
                {
                    return(View("ContinueRequest"));
                }
            }

            //new user and new request
            nuser.IsNewUser = true;
            if (nuser.IsNewUser)
            {
                var usercreated = await
                                  _userAppService.CreateAsync(nuser,
                                                              nuser.Identification + ConfigurationManager.AppSettings["Salt"]);

                if (!usercreated.Succeeded && usercreated.Errors.Any())
                {
                    return(View("Register"));
                }
                //error creating user
                if (!usercreated.Succeeded | usercreated.Errors.Any())
                {
                    foreach (var error in usercreated.Errors)
                    {
                        ModelState.AddModelError("", error);
                    }
                    var allErrors = ModelState.Values.SelectMany(v => v.Errors);
                    var message   = Join(", ", allErrors.Select(s => s.ErrorMessage).ToArray());
                    TempData["Message"] = message;
                    return(View("Register", new UserViewModel
                    {
                        ProductId = Convert.ToInt32((int)Session["Product"])
                    }));
                }
            }
            var identity =
                await _userAppService.CreateIdentityAsync(nuser, DefaultAuthenticationTypes.ApplicationCookie);

            identity.Label = nuser.FullName;
            GetAuthenticationManager().SignIn(identity);
            var principal = new ClaimsPrincipal(identity);

            Thread.CurrentPrincipal = principal;
            HttpContext.User        = principal;
            BaseProductType         = productid;
            BaseProductType         = productid;

            InitSetFormArguments(fields);
            var pages = _userAppService.GetAllPagesWithSections();

            ViewBag.Pages    = pages;
            ViewBag.FullName = identity.Label;

            var stepresult = await ExecuteFlowAsync(identity, pages);

            return(ValidateStepResult(stepresult));
        }