public async Task <JsonResult> Insert() { try { var id = Guid.NewGuid(); var api = Guid.Parse(Request.Form["api"]); var compID = Guid.Parse(Request.Form["cid"]); var roomName = Request.Form["name"]; //first check if api is valid var access = CompanyAPIKeyService.GetByAPIKeyCompID(api, compID); if (access != null) { //if api is valid insert room if (CloudMessagingRoomService.Insert(id, roomName, api, false)) { //returns the id of the room return(Json(new { success = true, data = id })); } return(Json(new { success = false, message = MessageUtility.DidNotFollowStandardUsingAPI() })); } return(Json(new { success = false, message = MessageUtility.APIKeyError() })); } catch { return(Json(new { success = false, message = MessageUtility.ServerError() })); } }