Method PostMaintainNames

Summary

Sets contact name and information for a new permit

Remarks

This method is called three times when creating a new permit application:

If you pass in a full 10 digit phone number into a phone field, it will set the area code from the phone field for proper submission.

Input Parameters

NameTypeLengthDescription
type System.String 1 Defaults to W for write mode.
sessionNumber numeric 9 [Required] Session Number from GetNewPermitSession
nameTypeCode System.String 2 CT for contractor, blank for sumitter
contractorNumber numeric 7 Contractor number from PostSearchByContractorName
name System.String 30 Contact name
addr1 System.String 30 Address line 1
addr2 System.String 30 Address line 2
addr3 System.String 30 Address line 3
zipCode System.String 9 Zip code. 9 char total
areaCode System.String 3 Work phone area code
phone System.String 10 Work phone number
areaCode2 System.String 3 Home phone area code
phone2 System.String 10 Home phone number
areaCode3 System.String 3 Cell phone area code
phone3 System.String 10 Cell phone number
areaCode4 System.String 3 Misc phone area code
phone4 System.String 10 Misc phone number
email System.String 50 Email address

Example

POST http://localhost/FusionServices/v3/Naviline/Permit/Application/Names

Sample Responses

Sample Code

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

public void MethodName(parms)
{
   string uri = "http://localhost/FusionServices/v3/Naviline/Permit/Application/Names";
   System.Collections.Specialized.NameValueCollection postParms = 
     new System.Collections.Specialized.NameValueCollection(); 
   // Set paramater values
   postParms.Add("sessionNumber",System.Web.HttpUtility.UrlEncode("000002131"));
   postParms.Add("nameTypeCode",System.Web.HttpUtility.UrlEncode("CT"));
   postParms.Add("contractorNumber",System.Web.HttpUtility.UrlEncode("806"));
   postParms.Add("name",System.Web.HttpUtility.UrlEncode("Fusion Contractor"));
   postParms.Add("addr1",System.Web.HttpUtility.UrlEncode("1000 Business Lane"));
   postParms.Add("addr2",System.Web.HttpUtility.UrlEncode("Lake Mary"));
   postParms.Add("zipCode",System.Web.HttpUtility.UrlEncode("32746"));
   postParms.Add("areaCode",System.Web.HttpUtility.UrlEncode("407"));
   postParms.Add("phone",System.Web.HttpUtility.UrlEncode("5551212"));
   postParms.Add("email",System.Web.HttpUtility.UrlEncode("Fusion@myemail.com"));

   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 PostMaintainNames
   {
       // Add property for each input param in order to map a field to it
       [RegularExpression("^(?=.{0,1}$).*", ErrorMessage = "Must be 1 characters or less. ")]
       public string type{get; set;}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

       public PostMaintainNames()
       {
           //Set any defaults here
       }
   }
}
@* NOTE: Use Add->View to add the View. *@
@* NOTE: Check the 'Create strongly-typed view checkbox, and select the PostMaintainNames 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.PostMaintainNames

@{
   ViewBag.Title = "PostMaintainNames";
}

<h2>PostMaintainNames</h2>
@using (Html.BeginForm()) {
   @Html.AntiForgeryToken()
   @Html.ValidationSummary(true)
   <fieldset>
   <legend>PostMaintainNames</legend>
       <div class="editor-label">
           @Html.LabelFor(model => model.type)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.type)
           @Html.ValidationMessageFor(model => model.type)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.sessionNumber)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.sessionNumber)
           @Html.ValidationMessageFor(model => model.sessionNumber)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.nameTypeCode)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.nameTypeCode)
           @Html.ValidationMessageFor(model => model.nameTypeCode)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.contractorNumber)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.contractorNumber)
           @Html.ValidationMessageFor(model => model.contractorNumber)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.name)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.name)
           @Html.ValidationMessageFor(model => model.name)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.addr1)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.addr1)
           @Html.ValidationMessageFor(model => model.addr1)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.addr2)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.addr2)
           @Html.ValidationMessageFor(model => model.addr2)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.addr3)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.addr3)
           @Html.ValidationMessageFor(model => model.addr3)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.zipCode)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.zipCode)
           @Html.ValidationMessageFor(model => model.zipCode)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.areaCode)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.areaCode)
           @Html.ValidationMessageFor(model => model.areaCode)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.phone)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.phone)
           @Html.ValidationMessageFor(model => model.phone)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.areaCode2)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.areaCode2)
           @Html.ValidationMessageFor(model => model.areaCode2)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.phone2)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.phone2)
           @Html.ValidationMessageFor(model => model.phone2)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.areaCode3)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.areaCode3)
           @Html.ValidationMessageFor(model => model.areaCode3)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.phone3)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.phone3)
           @Html.ValidationMessageFor(model => model.phone3)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.areaCode4)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.areaCode4)
           @Html.ValidationMessageFor(model => model.areaCode4)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.phone4)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.phone4)
           @Html.ValidationMessageFor(model => model.phone4)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.email)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.email)
           @Html.ValidationMessageFor(model => model.email)
       </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/PostMaintainNames
public ActionResult PostMaintainNames()
{
   // Create a new instance of the model to pick up any default values.
   PostMaintainNames model =  new PostMaintainNames();

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

// 
// POST: /MyController/PostMaintainNames
[HttpPost]
public ActionResult PostMaintainNames(FormCollection collection)
{
   string url = "v3/Naviline/Permit/Application/Names";
   // Get the value from each input field
   NameValueCollection inputParms = new NameValueCollection();
   inputParms.Add("type", collection["type"]);
   inputParms.Add("sessionNumber", collection["sessionNumber"]);
   inputParms.Add("nameTypeCode", collection["nameTypeCode"]);
   inputParms.Add("contractorNumber", collection["contractorNumber"]);
   inputParms.Add("name", collection["name"]);
   inputParms.Add("addr1", collection["addr1"]);
   inputParms.Add("addr2", collection["addr2"]);
   inputParms.Add("addr3", collection["addr3"]);
   inputParms.Add("zipCode", collection["zipCode"]);
   inputParms.Add("areaCode", collection["areaCode"]);
   inputParms.Add("phone", collection["phone"]);
   inputParms.Add("areaCode2", collection["areaCode2"]);
   inputParms.Add("phone2", collection["phone2"]);
   inputParms.Add("areaCode3", collection["areaCode3"]);
   inputParms.Add("phone3", collection["phone3"]);
   inputParms.Add("areaCode4", collection["areaCode4"]);
   inputParms.Add("phone4", collection["phone4"]);
   inputParms.Add("email", collection["email"]);

   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", "PostMaintainNames");
       return View("Error", info);
   }
}