Save permit information on a new application
This is called before PostWriteApplication saves the application to NaviLine.
Name | Type | Length | Description |
---|---|---|---|
sessionNumber | numeric | 9 | [Required] 9 digit session id. Use GetNewPermitSession to get the Session number |
permitType | System.String | 300 | [Required] Permit Type Code. See GetApplTypeCodesSpecific |
POST http://localhost/FusionServices/v3/Naviline/Permit/Application/WritePermit
using System.Net;
using Newtonsoft.Json.Linq;
public void MethodName(parms)
{
string uri = "http://localhost/FusionServices/v3/Naviline/Permit/Application/WritePermit";
System.Collections.Specialized.NameValueCollection postParms =
new System.Collections.Specialized.NameValueCollection();
// Set paramater values
postParms.Add("sessionNumber",System.Web.HttpUtility.UrlEncode("000002133"));
postParms.Add("permitType",System.Web.HttpUtility.UrlEncode("FENC"));
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
}
}
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 PostWritePermit
{
// 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 sessionNumber{get; set;}
[Required(ErrorMessage = "Required")]
[RegularExpression("^(?=.{0,300}$).*", ErrorMessage = "Must be 300 characters or less. ")]
public string permitType{get; set;}
public PostWritePermit()
{
//Set any defaults here
}
}
}
@* NOTE: Use Add->View to add the View. *@
@* NOTE: Check the 'Create strongly-typed view checkbox, and select the PostWritePermit 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.PostWritePermit
@{
ViewBag.Title = "PostWritePermit";
}
<h2>PostWritePermit</h2>
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>PostWritePermit</legend>
<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.permitType)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.permitType)
@Html.ValidationMessageFor(model => model.permitType)
</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/PostWritePermit
public ActionResult PostWritePermit()
{
// Create a new instance of the model to pick up any default values.
PostWritePermit model = new PostWritePermit();
// pass model to set to default values
// NOTE: Change 'MyFolderPath' to the path to the .cshtml file.
return View("~/Views/MyFolderPath/PostWritePermit.cshtml", model);
}
//
// POST: /MyController/PostWritePermit
[HttpPost]
public ActionResult PostWritePermit(FormCollection collection)
{
string url = "v3/Naviline/Permit/Application/WritePermit";
// Get the value from each input field
NameValueCollection inputParms = new NameValueCollection();
inputParms.Add("sessionNumber", collection["sessionNumber"]);
inputParms.Add("permitType", collection["permitType"]);
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", "PostWritePermit");
return View("Error", info);
}
}