Exemplo n.º 1
0
        public static IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            // should be a soft SimpleIssue
            // { "Title": "Test Simple Ticket", "Description": "This is a Test Simple Ticket" }
            dynamic data = JsonConvert.DeserializeObject(new StreamReader(req.Body).ReadToEnd());

            var iTitle = WebUtility.UrlDecode(req.Query["Title"]) ?? data?.Title;
            var iDesc  = WebUtility.UrlDecode(req.Query["Description"]) ?? data?.Description;

            var simpleIssue = new SimpleIssue()
            {
                Title = iTitle, Description = iDesc
            };

            // TODO: Catch Validation Errors
            var dtoIssue = Map(simpleIssue);

            var resp = CreateIssue(dtoIssue);

            // TODO: Figure out format of return
            // return url
            return(new BadRequestResult());
        }
Exemplo n.º 2
0
        private static DtoIssue Map(SimpleIssue issue)
        {
            // TODO: Validate Title
            // TODO: Validate Description

            var mappedIssue = new DtoIssue()
            {
                ProjectId   = _config.ConfiguredProject.ProjectId,
                TrackerId   = _config.ConfiguredProject.TrackerId,
                StatusId    = _config.ConfiguredProject.StatusId,
                PriorityId  = _config.ConfiguredProject.PriorityId,
                Title       = issue.Title,
                Description = issue.Description
            };

            if (_config.ConfiguredProject.CustomFields != null)
            {
                mappedIssue.CustomFields = _config.ConfiguredProject.CustomFields;
            }

            return(mappedIssue);
        }