Method PostCase

Summary

Add a Code Enforcement case

Remarks

This will allow a citizen to enter a case through Fusion. Vendors should check with the city to identify what type codes and status codes to send for cases coming from fusion. Cases will be processed in Naviline based on the codes sent.

Input Parameters

NameTypeLengthDescription
locationID numeric 9 [Required] Location ID for the address
caseTypeCode System.String 4 [Required] Case Type Code. See GetCaseTypeCodes
caseStatusCode System.String 2 [Required] Case Status code. Ex. AC=Active, CC=Case Closed.
caseOrigCode System.String 2 [Required] Case Origin code. Ex. CC=Citizen Complaint.
defaultInspectorID System.String 6 [Required] Default inspector ID. This is normally the inspector's initials
tenantName System.String 30 Tenant name
tenantNumber numeric 6 Tenant number. Max 6 digits.

Example

POST http://localhost/FusionServices/v3/Naviline/CodeEnforcement/Case

Return Values

NameDescription
ErrorCode Error Code. 0000 = success.
ErrorMessage Error Message. Success or error message description for the error code.
caseYear Case Year. 2 digit.
CaseNumber Case Number assigned to case. 8 digit.

Sample Responses

Sample Code

using System.Net;
using Newtonsoft.Json.Linq;

public void MethodName(parms)
{
   string uri = "http://localhost/FusionServices/v3/Naviline/CodeEnforcement/Case";
   System.Collections.Specialized.NameValueCollection postParms = 
     new System.Collections.Specialized.NameValueCollection(); 
   // Set paramater values
   postParms.Add("locationID",System.Web.HttpUtility.UrlEncode("10078"));
   postParms.Add("caseTypeCode",System.Web.HttpUtility.UrlEncode("SIGN"));
   postParms.Add("caseStatusCode",System.Web.HttpUtility.UrlEncode("AC"));
   postParms.Add("caseOrigCode",System.Web.HttpUtility.UrlEncode("RI"));
   postParms.Add("defaultInspectorID",System.Web.HttpUtility.UrlEncode("TARA"));
   postParms.Add("tenantName",System.Web.HttpUtility.UrlEncode(""));
   postParms.Add("tenantNumber",System.Web.HttpUtility.UrlEncode(""));

   WebClient req = new WebClient();
   wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
   wc.Headers.Set("X-APPID", "YOURID");
   wc.Headers.Set("X-APPKEY", "YOURKEY");

   byte[] responseBytes = wc.UploadValues(new Uri(uri), "POST", postParms);
   string stringResult = Encoding.UTF8.GetString(responseBytes); 
   JObject response = JObject.Parse(stringResult);
   string error = response["OutputParms"]["ErrorCode"].ToString();
   if (error == "0000")
   {
         // TODO - YOUR CODE HERE
   }
}

C# Razor MVC Sample Code

using System;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Collections.Specialized;
using FusionServiceHelper.Models;

// NOTE: Use the namespace generated when you add the class, so that it is correct.
namespace FusionRazor.Models
{
   public class PostCase
   {
       // Add property for each input param in order to map a field to it
       [Required(ErrorMessage = "Required")]
       [RegularExpression("[0-9]{0,9}", ErrorMessage = "Numeric values only. Must be 9 digits or less. ")]
       public string locationID{get; set;}

       [Required(ErrorMessage = "Required")]
       [RegularExpression("^(?=.{0,4}$).*", ErrorMessage = "Must be 4 characters or less. ")]
       public string caseTypeCode{get; set;}

       [Required(ErrorMessage = "Required")]
       [RegularExpression("^(?=.{0,2}$).*", ErrorMessage = "Must be 2 characters or less. ")]
       public string caseStatusCode{get; set;}

       [Required(ErrorMessage = "Required")]
       [RegularExpression("^(?=.{0,2}$).*", ErrorMessage = "Must be 2 characters or less. ")]
       public string caseOrigCode{get; set;}

       [Required(ErrorMessage = "Required")]
       [RegularExpression("^(?=.{0,6}$).*", ErrorMessage = "Must be 6 characters or less. ")]
       public string defaultInspectorID{get; set;}

       [RegularExpression("^(?=.{0,30}$).*", ErrorMessage = "Must be 30 characters or less. ")]
       public string tenantName{get; set;}

       [RegularExpression("[0-9]{0,6}", ErrorMessage = "Numeric values only. Must be 6 digits or less. ")]
       public string tenantNumber{get; set;}

       public PostCase()
       {
           //Set any defaults here
       }
   }
}
@* NOTE: Use Add->View to add the View. *@
@* NOTE: Check the 'Create strongly-typed view checkbox, and select the PostCase class. *@
@* NOTE: Select Edit as the Scaffold template. *@
@* NOTE: Use the @model line that is generated at the top.  Replace the rest with the lines below.
@model FusionRazor.Models.PostCase

@{
   ViewBag.Title = "PostCase";
}

<h2>PostCase</h2>
@using (Html.BeginForm()) {
   @Html.AntiForgeryToken()
   @Html.ValidationSummary(true)
   <fieldset>
   <legend>PostCase</legend>
       <div class="editor-label">
           @Html.LabelFor(model => model.locationID)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.locationID)
           @Html.ValidationMessageFor(model => model.locationID)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.caseTypeCode)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.caseTypeCode)
           @Html.ValidationMessageFor(model => model.caseTypeCode)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.caseStatusCode)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.caseStatusCode)
           @Html.ValidationMessageFor(model => model.caseStatusCode)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.caseOrigCode)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.caseOrigCode)
           @Html.ValidationMessageFor(model => model.caseOrigCode)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.defaultInspectorID)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.defaultInspectorID)
           @Html.ValidationMessageFor(model => model.defaultInspectorID)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.tenantName)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.tenantName)
           @Html.ValidationMessageFor(model => model.tenantName)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.tenantNumber)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.tenantNumber)
           @Html.ValidationMessageFor(model => model.tenantNumber)
       </div>
       <p>
       <input type="submit" value="Submit"/>
       </p>
   </fieldset>

}

@section Scripts {
   @Scripts.Render("~/bundles/jqueryval")
}
using System;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FusionServiceHelper.Models;

// NOTE: Replace 'MyController' with the name of your controller.

// 
// GET: /MyController/PostCase
public ActionResult PostCase()
{
   // Create a new instance of the model to pick up any default values.
   PostCase model =  new PostCase();

   // pass model to set to default values
   // NOTE: Change 'MyFolderPath' to the path to the .cshtml file.
   return View("~/Views/MyFolderPath/PostCase.cshtml", model);
}

// 
// POST: /MyController/PostCase
[HttpPost]
public ActionResult PostCase(FormCollection collection)
{
   string url = "v3/Naviline/CodeEnforcement/Case";
   // Get the value from each input field
   NameValueCollection inputParms = new NameValueCollection();
   inputParms.Add("locationID", collection["locationID"]);
   inputParms.Add("caseTypeCode", collection["caseTypeCode"]);
   inputParms.Add("caseStatusCode", collection["caseStatusCode"]);
   inputParms.Add("caseOrigCode", collection["caseOrigCode"]);
   inputParms.Add("defaultInspectorID", collection["defaultInspectorID"]);
   inputParms.Add("tenantName", collection["tenantName"]);
   inputParms.Add("tenantNumber", collection["tenantNumber"]);

   try
   {
       // Send the request
       FusionServiceRequest request = new FusionServiceRequest();
       FusionServiceResult result = request.Post(url, inputParms);

       return View("Result", result);
   }
   catch(Exception e)
   {
       HandleErrorInfo info = new HandleErrorInfo(e, "MyController", "PostCase");
       return View("Error", info);
   }
}