Example #1
0
        public HttpResponseMessage Get(
            [FromUri] string tenant,
            [FromUri] string token,
            [FromUri] string select = null
            )
        {
            if (!Factory.FeatureSwitch.Get("enableWfUserActionNotify"))
            {
                return(new HttpResponseMessage(System.Net.HttpStatusCode.NotFound));
            }

            using (Profiler.Measure("ApproveController.Approve"))
            {
                using (WebApiHelpers.GetTenantContext(tenant))
                {
                    string responseHtml = null;

                    var task = UserTaskHelper.GetTaskFromLinkToken(token);

                    if (task == null)
                    {
                        responseHtml = _htmlGenerator.GenerateRejectionPage();
                    }
                    else
                    {
                        if (select == null)
                        {
                            responseHtml = _htmlGenerator.GenerateSelectionPage(task);
                        }
                        else
                        {
                            // TODO: make the selection]
                            UserTaskHelper.ProcessApproval(task.Id, select);
                            responseHtml = _htmlGenerator.GenerateCompletedPage(task);
                        }
                    }

                    var response = new HttpResponseMessage(System.Net.HttpStatusCode.Accepted);
                    response.Content = new StringContent(responseHtml, Encoding.UTF8, "text/html");

                    return(response);
                }
            }
        }