예제 #1
0
        public static bool SetHeaderLocation(this HttpResponseMessage response, HttpRequestMessage request, ActionResult result, NameValueCollection queryStringParams = null)
        {
            var url = new System.Web.Http.Routing.UrlHelper(request);

            var routeVals     = result.GetRouteValueDictionary();
            var responseRoute = url.Route(null, routeVals);

            if (!string.IsNullOrWhiteSpace(responseRoute))
            {
                var routeUri = new Uri(request.RequestUri, responseRoute);
                var query    = HttpUtility.ParseQueryString(routeUri.Query);
                if (queryStringParams != null)
                {
                    query.Add(queryStringParams);
                    responseRoute = string.Format("{0}{1}",
                                                  routeUri.AbsolutePath,
                                                  query.HasKeys()
                                                      ? string.Format("?{0}", query)
                                                      : string.Empty);
                }

                response.Headers.Location = new Uri(request.RequestUri, responseRoute);
                return(true);
            }

            return(false);
        }
예제 #2
0
 public async static Task <HttpResponseMessage> IntegrationUploadAsync(
     [QueryParameter(CheckFileName = true)] Guid integration,
     EastFive.Security.SessionServer.Context context,
     HttpRequestMessage request, System.Web.Http.Routing.UrlHelper url,
     ViewFileResponse onLoadUploadPage)
 {
     return(await onLoadUploadPage("SheetIntegration/UploadSheet.cshtml", null).ToTask());
 }
예제 #3
0
 /// <summary>
 /// Generates a fully qualified URL for the specified route values.
 /// </summary>
 /// <param name="urlHelper">The URL helper.</param>
 /// <param name="routeName">Name of the route.</param>
 /// <param name="controller">The controller.</param>
 /// <param name="mainArgument">The main argument.</param>
 /// <returns>
 /// Returns a fully-qualified URL.
 /// </returns>
 public static string Link(this System.Web.Http.Routing.UrlHelper urlHelper, string routeName,
                           string controller, string mainArgument = null)
 {
     Throw.IfArgumentNull(urlHelper, "urlHelper");
     Throw.IfArgumentNullOrEmpty(routeName, "routeName");
     Throw.IfArgumentNullOrEmpty(controller, "controller");
     return(urlHelper.Link(routeName, new { controller = controller, mainArgument = mainArgument }));
 }
예제 #4
0
        void SetupHateos(ApiController controller)
        {
            var urlHelper = new System.Web.Http.Routing.UrlHelper();

            urlHelper.Request             = new System.Net.Http.HttpRequestMessage();
            urlHelper.Request.RequestUri  = new System.Uri("http://localhost/test");
            urlHelper.Request.Method      = System.Net.Http.HttpMethod.Get;
            controller.RequestContext.Url = urlHelper;
        }
예제 #5
0
        public static List <LinkModel> SetLinks(System.Web.Http.Routing.UrlHelper urlHelper, string routeName, string controller, string method, int id = 0)
        {
            object           route = null;
            List <LinkModel> links = new List <LinkModel>();

            switch (controller.ToUpper())
            {
            case ("INSTRUCTORS"):
                switch (method.ToUpper())
                {
                case "GET":
                case "POST":
                case "DELETE":
                    route = new { controller = controller };
                    links.Add(new LinkModel("get instructors", urlHelper.Link(routeName, route), RestRequestVerb.GET));
                    links.Add(new LinkModel("post instructor", urlHelper.Link(routeName, route), RestRequestVerb.POST));
                    if (id > 0)
                    {
                        route = new { controller = controller, id = id };
                        links.Add(new LinkModel("get instructor", urlHelper.Link(routeName, route), RestRequestVerb.GET));
                        links.Add(new LinkModel("delete instructor", urlHelper.Link(routeName, route), RestRequestVerb.DELETE));
                    }

                    break;
                }
                break;

            case ("CLASSES"):
                switch (method.ToUpper())
                {
                case "GET":
                case "POST":
                case "DELETE":
                    route = new { controller = controller };
                    links.Add(new LinkModel("get classes", urlHelper.Link(routeName, route), RestRequestVerb.GET));
                    links.Add(new LinkModel("post classes", urlHelper.Link(routeName, route), RestRequestVerb.POST));
                    if (id > 0)
                    {
                        route = new { controller = controller, id = id };
                        links.Add(new LinkModel("get class", urlHelper.Link(routeName, route), RestRequestVerb.GET));
                        links.Add(new LinkModel("delete class", urlHelper.Link(routeName, route), RestRequestVerb.DELETE));
                    }

                    break;
                }
                break;

            default:
                break;
            }

            return(links);
        }
    public static string RouteUrl(string routeName, object routeValues = null)
    {
        var url = String.Empty;

        try
        {
            var helper = new System.Web.Http.Routing.UrlHelper();
            return(helper.Link(routeName, routeValues));
        }
        catch
        {
            return(url);
        }
    }
예제 #7
0
        private static async Task <HttpResponseMessage> QueryAsVideoStream(
            [QueryParameter(CheckFileName = true, Name = ContentIdPropertyName)] Guid contentId,
            [QueryParameter(Name = StreamingPropertyName)] bool streaming,
            HttpRequestMessage request,
            EastFive.Api.Security security,
            System.Web.Http.Routing.UrlHelper url)
        {
            var response = await EastFive.Api.Azure.Content.FindContentByContentIdAsync(contentId,
                                                                                        security,
                                                                                        (contentType, video) => request.CreateResponseVideoStream(video, contentType),
                                                                                        () => request.CreateResponse(HttpStatusCode.NotFound),
                                                                                        () => request.CreateResponse(HttpStatusCode.Unauthorized));

            return(response);
        }
예제 #8
0
        public static async Task <HttpResponseMessage> QueryByContentIdAsync(
            [QueryParameter(CheckFileName = true, Name = ContentIdPropertyName)] Guid contentId,
            [OptionalQueryParameter] int?width,
            [OptionalQueryParameter] int?height,
            [OptionalQueryParameter] bool?fill,
            [OptionalQueryParameter] string renderer,
            HttpRequestMessage request,
            System.Web.Http.Routing.UrlHelper url)
        {
            var response = await EastFive.Api.Azure.Content.FindContentByContentIdAsync(contentId,
                                                                                        (contentType, image) =>
            {
                if (renderer.HasBlackSpace())
                {
                    if (renderer.ToLower() == "unzip")
                    {
                        using (var compressedStream = new MemoryStream(image))
                            using (var zipStream = new System.IO.Compression.ZipArchive(compressedStream, ZipArchiveMode.Read))
                                using (var resultStream = new MemoryStream())
                                {
                                    var zipFile = zipStream.Entries.First();
                                    zipFile.Open().CopyTo(resultStream);
                                    var data = resultStream.ToArray();
                                    return(request.CreateFileResponse(data, "application/object", filename: zipFile.Name));
                                }
                    }
                }

                if (contentType.StartsWith("video", StringComparison.InvariantCultureIgnoreCase) &&
                    (width.HasValue || height.HasValue || fill.HasValue))
                {
                    var videoPreviewImage = default(System.Drawing.Image);     // Properties.Resources.video_preview;
                    return(request.CreateImageResponse(videoPreviewImage,
                                                       width: width, height: height, fill: fill,
                                                       filename: contentId.ToString("N")));
                }
                return(request.CreateImageResponse(image,
                                                   width: width, height: height, fill: fill,
                                                   filename: contentId.ToString("N"),
                                                   contentType: contentType));
            },
                                                                                        () => request.CreateResponse(HttpStatusCode.NotFound),
                                                                                        () => request.CreateResponse(HttpStatusCode.Unauthorized));

            return(response);
        }
        public static string ToPublicUrl(this System.Web.Http.Routing.UrlHelper urlHelper, Uri relativeUri)
        {
            var requestUrl = urlHelper.Request.RequestUri;

            var uriBuilder = new UriBuilder
            {
                Host   = requestUrl.Host,
                Path   = "/",
                Port   = 80,
                Scheme = "http",
            };

#if DEBUG
            uriBuilder.Port = requestUrl.Port;
#endif

            return(new Uri(uriBuilder.Uri, relativeUri).AbsoluteUri);
        }
        public static async Task <TResult> ProcessRequestAsync <TResult>(
            EastFive.Azure.Auth.Method method,
            IDictionary <string, string> values,
            AzureApplication application, HttpRequestMessage request,
            System.Web.Http.Routing.UrlHelper urlHelper,
            Func <Uri, TResult> onRedirect,
            Func <string, TResult> onBadCredentials,
            Func <string, TResult> onCouldNotConnect,
            Func <string, TResult> onFailure)
        {
            var authorizationRequestManager = application.AuthorizationRequestManager;

            var telemetry = application.Telemetry;

            telemetry.TrackEvent($"ResponseController.ProcessRequestAsync - Requesting credential manager.");

            var requestId   = Guid.NewGuid();
            var redirection = new Redirection
            {
                webDataRef     = requestId.AsRef <Redirection>(),
                method         = method.authenticationId,
                values         = values,
                redirectedFrom = request.Headers.Referrer,
            };

            return(await await redirection.StorageCreateAsync(
                       discard =>
            {
                var baseUri = request.RequestUri;
                return AuthenticationAsync(requestId,
                                           method, values, baseUri, application,
                                           onRedirect,
                                           () => onFailure("Authorization not found"),
                                           onCouldNotConnect,
                                           onFailure);
            },
                       () => onFailure("GUID NOT UNIQUE").AsTask()));
        }
예제 #11
0
 public ModelFactory(HttpRequestMessage request)
 {
     _UrlHelper = new System.Web.Http.Routing.UrlHelper(request);
 }
예제 #12
0
 public ModelFactory(HttpRequestMessage request, ILearningRepository repo)
 {
     _UrlHelper = new System.Web.Http.Routing.UrlHelper(request);
     _repo      = repo;
 }
        public async static Task <HttpResponseMessage> XlsPostAsync(EastFive.Security.SessionServer.Context context,
                                                                    [QueryParameter] Guid integration,
                                                                    [QueryParameter] IDictionary <string, bool> resourceTypes,
                                                                    Azure.AzureApplication application,
                                                                    HttpRequestMessage request, System.Web.Http.Routing.UrlHelper url,
                                                                    RedirectResponse onSuccess,
                                                                    NotFoundResponse onNotFound,
                                                                    GeneralConflictResponse onError)
        {
            var resourceTypesList = resourceTypes.SelectKeys().Join(",");

            return(onSuccess(
                       url.GetLocation <InternalIntegrationResponseController>(
                           (irc) => irc.IntegrationId.AssignQueryValue(integration),
                           (irc) => irc.ResourceTypes.AssignQueryValue(resourceTypesList),
                           application)));
        }
 public async static Task <HttpResponseMessage> IntegrationUploadAsync(EastFive.Security.SessionServer.Context context,
                                                                       [QueryParameter(CheckFileName = true, Name = StateQueryParameter)] Guid integrationId,
                                                                       HttpRequestMessage request, System.Web.Http.Routing.UrlHelper url,
                                                                       ViewFileResponse onLoadUploadPage)
 {
     return(await onLoadUploadPage("InternalIntegration/ConfigureIntegration.cshtml", integrationId).ToTask());
 }
예제 #15
0
 public ModelFactory(HttpRequestMessage request, ILearningRepository repo)
 {
     _UrlHelper = new System.Web.Http.Routing.UrlHelper(request);
     _repo = repo;
 }
예제 #16
0
        public async static Task <HttpResponseMessage> XlsPostAsync(EastFive.Security.SessionServer.Context context,
                                                                    ContentBytes sheet, [QueryParameter] Guid integration, IDictionary <string, bool> resourceTypes,
                                                                    HttpRequestMessage request, System.Web.Http.Routing.UrlHelper url,
                                                                    RedirectResponse onSuccess,
                                                                    NotFoundResponse onNotFound,
                                                                    GeneralConflictResponse onError)
        {
            var sheetId = Guid.NewGuid();

            return(await await context.Integrations.UpdateAsync(integration,
                                                                sheet.content.MD5HashGuid().ToString("N"),
                                                                new Dictionary <string, string>()
            {
                { "resource_types", resourceTypes.SelectKeys().Join(",") },
                { "sheet_id", sheetId.ToString("N") },
            },
                                                                (redirectUrl) =>
            {
                return EastFive.Api.Azure.Credentials.Sheets.SaveAsync(sheetId, sheet.contentType.MediaType, sheet.content, integration,
                                                                       context.DataContext,
                                                                       () => onSuccess(redirectUrl),
                                                                       "Guid not unique".AsFunctionException <HttpResponseMessage>());
            },
                                                                () => onNotFound().ToTask(),
                                                                () => onError("The provided integration ID has not been connected to an authorization.").ToTask()));
        }
예제 #17
0
        public static async Task <HttpResponseMessage> Get(
            [OptionalQueryParameter(CheckFileName = true)] string tag,
            [QueryParameter(Name = TokenIdPropertyName)] string tokenId,
            [QueryParameter(Name = AgentIdPropertyName)] string agentId,
            AzureApplication application,
            HttpRequestMessage request,
            System.Web.Http.Routing.UrlHelper urlHelper,
            RedirectResponse onRedirectResponse,
            BadRequestResponse onBadCredentials,
            HtmlResponse onCouldNotConnect,
            HtmlResponse onGeneralFailure)
        {
            //The way this works...
            //1.  User clicks Third Party Applications\AffirmHealth over in Athena.
            //2.  Athena calls Ping
            //3.  Ping redirects to /PingResponseController with a token.
            //4.  This code validates the token, parses it out, and redirects to the interactive report matching the patient id.

            //To debug, you have to grab the token from Ping that comes in here.  If you don't, the token will get used and it won't work again
            //To do this, uncomment the commented line and comment out the call to ParsePingResponseAsync.  That way the token won't be used.
            //After the uncomment/comment, publish to dev and then click third party apps\Affirm Health in Athena.
            //Grab the token from the browser.
            //Then, switch the uncommented/commented lines back and run the server in debug.
            //Send the token via Postman to debug and see any errors that might come back from Ping.

            //return onRedirectResponse(new Uri("https://www.google.com"));

            if (tag.IsNullOrWhiteSpace())
            {
                tag = "OpioidTool";
            }

            var methodName = Enum.GetName(typeof(CredentialValidationMethodTypes), CredentialValidationMethodTypes.Ping);
            var method     = await EastFive.Azure.Auth.Method.ByMethodName(methodName, application);

            var failureHtml = "<html><title>{0}</title><body>{1} Please report:<code>{2}</code> to Affirm Health if the issue persists.</body></html>";

            return(await EastFive.Web.Configuration.Settings.GetString($"AffirmHealth.PDMS.PingRedirect.{tag}.PingAuthName",
                                                                       async pingAuthName =>
            {
                return await EastFive.Web.Configuration.Settings.GetGuid($"AffirmHealth.PDMS.PingRedirect.{tag}.PingReportSetId",
                                                                         async reportSetId =>
                {
                    var requestParams = request.GetQueryNameValuePairs()
                                        .Append("PingAuthName".PairWithValue(pingAuthName))
                                        .Append("ReportSetId".PairWithValue(reportSetId.ToString()))
                                        .ToDictionary();

                    return await Redirection.ProcessRequestAsync(method,
                                                                 requestParams,
                                                                 application, request, urlHelper,
                                                                 (redirect) =>
                    {
                        return onRedirectResponse(redirect);
                    },
                                                                 (why) => onBadCredentials().AddReason(why),
                                                                 (why) =>
                    {
                        var failureText = String.Format(failureHtml,
                                                        "PING/ATHENA credential service offline",
                                                        "Could not connect to PING (the authorization service used by Athena) to verify the provided link. Affirm Health will work with Athena/Ping to resolve this issue.",
                                                        why);
                        return onCouldNotConnect(why);
                    },
                                                                 (why) =>
                    {
                        var failureText = String.Format(failureHtml,
                                                        "Failed to authenticate",
                                                        "You could not be authenticated.",
                                                        why);
                        return onGeneralFailure(why);
                    });
                },
                                                                         why =>
                {
                    return onGeneralFailure(why).AsTask();
                });
            },
                                                                       why =>
            {
                return onGeneralFailure(why).AsTask();
            }));
        }
예제 #18
0
 public ModelFactory(HttpRequestMessage request)
 {
     _UrlHelper = new System.Web.Http.Routing.UrlHelper(request);
 }
예제 #19
0
        public async Task <IHttpActionResult> Get(string fields = null,
                                                  string sort   = "NickName",
                                                  string userId = null,
                                                  int page      = 1,
                                                  int pageSize  = maxPageSize)
        {
            try
            {
                Guid userIdGuid;
                Guid?Id = null;
                if (Guid.TryParse(userId, out userIdGuid))
                {
                    Id = userIdGuid;
                }
                IQueryable <User> users = await _repository.GetUsersAsync(Id);

                List <string> lstOfFields = new List <string>();

                if (fields != null)
                {
                    lstOfFields = fields.ToLower().Split(',').ToList();
                }

                users = users.ApplySort(sort)
                        .Where(eg => (userId == null || eg.UserId == Id));

                // ensure the page size isn't larger than the maximum.
                if (pageSize > maxPageSize)
                {
                    pageSize = maxPageSize;
                }

                // calculate data for metadata
                var totalCount = users.Count();
                var totalPages = (int)Math.Ceiling((double)totalCount / pageSize);

                var urlHelper = new System.Web.Http.Routing.UrlHelper(Request);
                var prevLink  = page > 1 ? urlHelper.Link("UsersList",
                                                          new
                {
                    page     = page - 1,
                    pageSize = pageSize,
                    sort     = sort,
                    fields   = fields,
                    userId   = userId
                }) : "";
                var nextLink = page < totalPages?urlHelper.Link("UsersList",
                                                                new
                {
                    page     = page + 1,
                    pageSize = pageSize,
                    sort     = sort,
                    fields   = fields,
                    userId   = userId
                }) : "";


                var paginationHeader = new
                {
                    currentPage      = page,
                    pageSize         = pageSize,
                    totalCount       = totalCount,
                    totalPages       = totalPages,
                    previousPageLink = prevLink,
                    nextPageLink     = nextLink
                };

                HttpContext.Current.Response.Headers.Add("X-Pagination",
                                                         Newtonsoft.Json.JsonConvert.SerializeObject(paginationHeader));


                // return result
                return(Ok(users
                          .Skip(pageSize * (page - 1))
                          .Take(pageSize)
                          .ToList()
                          .Select(eg => _uFactory.CreateDataShapedObject(eg, lstOfFields))));
            }
            catch (Exception e)
            {
                //todo logghiamo ?
                return(InternalServerError());
            }
        }
예제 #20
0
        public List <dynamic> RegisterFull(FormDataCollection formData)
        {
            List <string> errors   = new List <string>();
            List <string> response = new List <string>();

            if (formData != null)
            {
                string name            = formData.Get("name");
                string surname         = formData.Get("surname");
                string password        = formData.Get("password");
                string confirmPassword = formData.Get("confirmPassword");
                string email           = formData.Get("email");
                string country         = formData.Get("country");
                string state           = formData.Get("state");
                string city            = formData.Get("city");
                string mobile          = formData.Get("mobile");
                string promo           = formData.Get("promo");
                string membershipType  = formData.Get("membershipType");
                string tnc             = formData.Get("TermsAndConditions");

                // Validation section - cascade errors
                if (string.IsNullOrEmpty(name))
                {
                    errors.Add("Name is required.");
                }

                if (string.IsNullOrEmpty(surname))
                {
                    errors.Add("Surname is required.");
                }

                if (string.IsNullOrEmpty(password))
                {
                    errors.Add("Password is required.");
                }

                if (string.IsNullOrEmpty(confirmPassword))
                {
                    errors.Add("Confirm Password is required.");
                }
                else
                {
                    if (password.Trim() != confirmPassword.Trim())
                    {
                        errors.Add("Passwords don't match");
                    }
                }

                if (string.IsNullOrEmpty(email))
                {
                    errors.Add("Email is required.");
                }
                else
                {
                    // check for existing.
                }

                if (string.IsNullOrEmpty(country))
                {
                    errors.Add("Country is required.");
                }
                else
                {
                    // validate country ID
                }

                if (string.IsNullOrEmpty(membershipType))
                {
                    errors.Add("Membership Type is required.");
                }
                else
                {
                    // validate membership type
                }

                if (string.IsNullOrEmpty(tnc))
                {
                    errors.Add("Terms and Conditions required.");
                }
                else
                {
                    if (tnc.Trim() != "1")
                    {
                        errors.Add("Terms and Conditions required.");
                    }
                }

                promo  = (string.IsNullOrEmpty(promo)) ? null : promo;
                city   = (string.IsNullOrEmpty(city)) ? "" : city;
                state  = (string.IsNullOrEmpty(state)) ? "" : state;
                mobile = (string.IsNullOrEmpty(mobile)) ? "" : mobile;

                if (errors.Count > 0)
                {
                    return(errors.ToList <dynamic>());
                }

                // No apparent errors, continue creation.
                int countryID = Convert.ToInt32(country.Trim());
                int?cityID    = null;
                int?stateID   = null;

                if (!(string.IsNullOrEmpty(city)))
                {
                    cityID = Convert.ToInt32(city.Trim());
                }

                if (!(string.IsNullOrEmpty(state)))
                {
                    stateID = Convert.ToInt32(state.Trim());
                }

                int    membershipTypeID = Convert.ToInt32(membershipType.Trim());
                int?   OwnerID          = getOwner(countryID, stateID, cityID, promo);
                string MobileNumber     = "";
                if (!string.IsNullOrEmpty(mobile))
                {
                    MobileNumber = Regex.Replace(mobile, @"\s+", "");
                }

                AccountHelper    accountHelper = new AccountHelper();
                AccountService   service       = new AccountService(db, UserManager);
                ApplicationUser  user;
                AccountViewModel avm = new AccountViewModel();
                avm.Email     = email.Trim();
                avm.CountryID = countryID;
                avm.CityID    = cityID;
                avm.FirstName = name.Trim();
                avm.LastName  = surname.Trim();
                avm.MemberSubscriptionType = membershipTypeID;
                avm.ownerID            = OwnerID;
                avm.Password           = password.Trim();
                avm.ConfirmPassword    = confirmPassword.Trim();
                avm.MobileNumber       = MobileNumber;
                avm.PromoCode          = (string.IsNullOrEmpty(promo)) ? "" : promo.Trim();
                avm.StateID            = stateID;
                avm.TermsAndConditions = Convert.ToBoolean(Convert.ToInt32(tnc.Trim()));
                IEnumerable <string> Ierrors;
                System.Web.Http.Routing.UrlHelper urlHelper = new System.Web.Http.Routing.UrlHelper(Request);

                if (service.createUser(accountHelper.ToMember(avm), avm.Password, out user, out Ierrors, urlHelper))
                {
                    GameDao gd = new GameDao(db);
                    gd.AddMemberToGame(user);
                    // Do user sign-in
                    string AuthToken = this.Authenticate(avm.Email, avm.Password);
                    // Get Member ID

                    Member member = service.findMember(avm.Email);
                    if (member == null)
                    {
                        errors.Add("Member not generated");
                        return(errors.ToList <dynamic>());
                    }

                    response.Add("AuthorizationToken::" + AuthToken);
                    response.Add("MemberID::" + member.MemberID);
                }
                if (Ierrors.Count() > 0)
                {
                    return(Ierrors.ToList <dynamic>());
                }
            }
            return(response.ToList <dynamic>());
        }
예제 #21
0
        public bool createUser(Member member, String password, out ApplicationUser user, out IEnumerable <String> errors, System.Web.Http.Routing.UrlHelper apiURLHelper)
        {
            user = new ApplicationUser()
            {
                UserName = member.EmailAddress, Email = member.EmailAddress
            };
            IdentityResult result    = userManager.Create(user, password);
            MemberDao      memberDao = new MemberDao(db);

            member.ASPUserId = user.Id;
            if (member.MemberAcquisitionCampaignCode.ToLower().Equals("launch"))
            {
                member.MemberSubscriptionTypeID = db.MemberSubscriptionTypes.Where(x => x.MemberSubscriptionTypeCode.ToLower().Equals("tycoon")).First().MemberSubscriptionTypeID;
            }
            if (result.Succeeded && memberDao.save(member))
            {
                sendWelcomeEmail(user.Id, user.Email, null, user.Email, apiURLHelper);
                errors = new List <String>();
                return(true);
            }
            errors = result.Errors;
            return(false);
        }
예제 #22
0
        private async void sendWelcomeEmail(String userId, String email, UrlHelper urlHelper, string recipientName, System.Web.Http.Routing.UrlHelper apiUrlHelper)
        {
            string CallbackURL = "";
            string code        = userManager.GenerateEmailConfirmationToken(userId);

            // webapi will send null urlhelper and defined base URL in CallbackURL
            if (urlHelper != null)
            {
                string protocol    = urlHelper.RequestContext.HttpContext.Request.Url.Scheme;
                var    callbackUrl = urlHelper.Action("ConfirmEmail", "Account", new { userId = userId, code = code }, protocol: protocol);
                CallbackURL = callbackUrl;
            }
            else
            {
                var callbackUrl = apiUrlHelper.Route("Default", new { userId = userId, code = code });
                CallbackURL = apiUrlHelper.Request.RequestUri.Scheme + "://" + apiUrlHelper.Request.RequestUri.Authority + "/" + callbackUrl;
            }


            EmailManager emailManager = new EmailManager();

            emailManager.NewEmail();
            emailManager.RecipientEmailAddress = email;
            emailManager.RecipientName         = recipientName;
            emailManager.EmailSubject          = " Welcome to VAULTLife.com! ";
            //emailManager.EmailBodyText = "<!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml'><head><title></title><link rel='stylesheet' href='http://www.vaultlife.com/Content/images/email/email-styles.css' /></head><body><link rel='stylesheet' href='http://www.vaultlife.com/Content/images/email/email-styles.css' /><div class='header' style='background-color: black;'><img src='https://www.vaultlife.com/Content/images/logo.png' /></div><div class='content'><h1> WELCOME</h1><p>Welcome to VAULTLife.com, a world in which anything is possible! Its time to stop worrying about probabilities and wondering about possibilities! Begin a journey today with VAULTLife.com where you replace your to-do list with your bucket list! </p><p>We all have different dreams. Our worlds are coloured with different fantasies and we want to help you achieve yours! Based on this, we would like to tailor make your VAULTLife.com experience, so please select the link below to confirm that your details are correct and that we have all we need to make your VAULTLife.com experience once in a lifetime! </p><p>Please confirm your account by clicking <a href=\"" + CallbackURL + "\">here</a></p></div><div class='footer'><table class='signature' cellspacing='0'><tr><td class='details'><img src='http://www.vaultlife.com/Content/images/email/vl-team-sig_01.jpg' alt='Vaultlife.com' /><div class='content'><h2>VAULTLife TEAM</h2><div><strong>Email:</strong> &nbsp; <a href='mailto:[email protected]'>[email protected]</a></div><div><strong>Tel:</strong> &nbsp; <span>+27 86 123 6334</span></div><div><strong>Fax:</strong> &nbsp; <span>+27 86 123 6334</span></div><div><span class='small'>The Embassy, 50 Mulbarton Rd, Beverly, Johannesburg, 1296</span></div><div><a href='http://www.vaultlife.com'><strong>www.vaultlife.com</strong></a></div></div></td><td class='promo'><img src='http://www.vaultlife.com/Content/images/email/vl-team-sig_02.jpg' alt='Vaultlife.com' /></td></tr></table></div></body></html>";
            emailManager.EmailBodyText = "<!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml'><head><title></title></head><body style='margin: 0px; padding: 0px;'><div class='header' style='background-color: black; padding: 15px 20px;'><img src='http://www.vaultlife.com/Content/images/logo.png' alt='Vaultlife.com' style='width: 127px; height: 39px;' /></div><div class='content' style='padding: 15px 30px; font-family: Segoe UI, Calibri, Arial, Helvetica, sans-serif; max-width: 800px; width: 100%;'><h1>WELCOME</h1><p>Welcome to VAULTLife.com, a world in which anything is possible! Its time to stop worrying about probabilities and wondering about possibilities! Begin a journey today with VAULTLife.com where you replace your to-do list with your bucket list!</p><p>We all have different dreams. Our worlds are coloured with different fantasies and we want to help you achieve yours! Based on this, we would like to tailor make your VAULTLife.com experience, so please select the link below to confirm that your details are correct and that we have all we need to make your VAULTLife.com experience once in a lifetime!</p><p>Please confirm your account by clicking <a href=\"" + CallbackURL + "\">here</a></p><p>code: " + code + "</p></div><div class='footer' style='padding: 15px 30px; font-family: 'Segoe UI', Calibri, Arial, Helvetica, sans-serif;'><table class='signature' cellspacing='0' cellpadding='0'><tr><td class='details' style='width: 308px; vertical-align: top; background-color: #161616;' valign='top'><img src='http://www.vaultlife.com/Content/images/email/vl-team-sig_01.jpg' alt='Vaultlife.com' style='width: 308px; height: 79px;' /><div class='content' style='padding: 0px 15px; font-size: 11px; color: white;'><h2 style='margin: 0px;font-size: 20px;'>VAULTLife TEAM</h2><div><strong>Email:</strong> &nbsp; <a href='mailto:[email protected]' style='color: #eeeeee;'>[email protected]</a></div><div><strong>Tel:</strong> &nbsp; <span>+27 86 123 6334</span></div><div><strong>Fax:</strong> &nbsp; <span>+27 86 123 6334</span></div><div><span class='small'>The Embassy, 50 Mulbarton Rd, Beverly, Johannesburg, 1296</span></div><div><a href='http://www.vaultlife.com' style='color: #eeeeee;'><strong>www.vaultlife.com</strong></a></div></div></td><td class='promo' valign='top' style='vertical-align: top; background-color: #161616; width: 220px'><img src='http://www.vaultlife.com/Content/images/email/vl-team-sig_02.jpg' alt='Vaultlife.com' style='width: 228px; height: 220px;' /></td></tr></table></div></body></html>";
            emailManager.QueueEmail();
        }