Skip to content

Instantly share code, notes, and snippets.

@sampetrosov
Created January 16, 2021 08:09
Show Gist options
  • Save sampetrosov/d29fd9c18078db3ffedcf944bb07b636 to your computer and use it in GitHub Desktop.
Save sampetrosov/d29fd9c18078db3ffedcf944bb07b636 to your computer and use it in GitHub Desktop.
using Newtonsoft.Json.Linq;
using PX.Data;
using PX.Export.Authentication;
using System.Web.Http;
using CustomController.Models;
using CustomController.Helpers;
using System.Web;
namespace CustomController
{
[RoutePrefix("api/v1/IIG")]
[BasicAuthorize]
public partial class IIGController : ApiController
{
[HttpPost]
[Route("PostData")]
public IHttpActionResult PostData([FromBody]JObject data)
{
var lead = data.ToObject<BusAccount>();
if (lead == null)
return BadRequest("Passed object structure is not corresponding to the requirements");
var retVal = BusAccount.CreateBusAccount(lead);
if (retVal)
return Ok();
else
return BadRequest("Error has been thrown while processing the data");
}
protected override void Dispose(bool disposing)
{
if (HttpContext.Current != null && HttpContext.Current.Session != null)
{
PXLogin.LogoutUser(PXAccess.GetUserName(), HttpContext.Current.Session.SessionID);
}
FormsAuthenticationModule.SignOut();
base.Dispose(disposing);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment