Пример #1
0
        public ActionResult Index(CreateUserFromInvitationModel createUser)
        {
            if (ModelState.IsValid)
            {
                var response = new PlatformManagementService.DataAccessResponseType();
                var platformManagementServiceClient = new PlatformManagementService.PlatformManagementServiceClient();

                try
                {
                    platformManagementServiceClient.Open();
                    response = platformManagementServiceClient.RegisterInvitedPlatformUser(createUser.Email, createUser.FirstName, createUser.LastName, createUser.Password, createUser.Role, createUser.InvitationCode, Common.SharedClientKey);

                    //Close the connection
                    WCFManager.CloseConnection(platformManagementServiceClient);
                }
                catch (Exception e)
                {
                    #region Manage Exception

                    string exceptionMessage = e.Message.ToString();

                    var    currentMethod       = System.Reflection.MethodBase.GetCurrentMethod();
                    string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name;

                    // Abort the connection & manage the exception
                    WCFManager.CloseConnection(platformManagementServiceClient, exceptionMessage, currentMethodString);

                    // Upate the response object
                    response.isSuccess    = false;
                    response.ErrorMessage = WCFManager.UserFriendlyExceptionMessage;
                    //response.ErrorMessages[0] = exceptionMessage;

                    #endregion
                }

                if (response.isSuccess)
                {
                    return(RedirectToAction("Success", "Invitations"));
                }
                else
                {
                    foreach (string error in response.ErrorMessages)
                    {
                        ModelState.AddModelError("Errors", error);
                    }
                    return(View(createUser));
                }
            }
            else
            {
                return(View(createUser));
            }
        }