/**
 * Retrieves the raw new endpoint data from a portal request and submit it
 * to the services layer's functions. Provides basic validation that the interface name is set and unique
 * @param \User $user current user
 * @return null */
function submit(\User $user = null)
{
    $serv = \Factory::getServiceService();
    $newValues = getEndpointDataFromWeb();
    $serviceid = $newValues['SERVICEENDPOINT']['SERVICE'];
    $serv->addEndpoint($newValues, $user);
    show_view("service/added_service_endpoint.php", $serviceid);
}
/**
 * Processes an edit endpoint request from a web request
 * @param \User $user current user
 * return null
 */
function submit(\User $user = null)
{
    try {
        $newValues = getEndpointDataFromWeb();
        $serviceID = $newValues['SERVICEENDPOINT']['SERVICE'];
        $endpointID = $newValues['SERVICEENDPOINT']['ENDPOINTID'];
        $serv = \Factory::getServiceService();
        $endpoint = $serv->getEndpoint($endpointID);
        $service = $serv->getService($serviceID);
        $serv->editEndpoint($service, $user, $endpoint, $newValues);
        $params['serviceid'] = $serviceID;
        $params['endpointid'] = $endpointID;
        show_view('service/service_endpoint_updated.php', $params);
    } catch (Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
}