public async Task <IHttpActionResult> Next([FromODataUri] String key, ODataActionParameters parameters) { var declaringType = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType; var fn = String.Format("{0}:{1}", declaringType.Namespace, declaringType.Name); try { Debug.WriteLine(fn); var identity = CurrentUserDataProvider.GetIdentity(TenantId); var permissionId = CreatePermissionId("CanNext"); if (!identity.Permissions.Contains(permissionId)) { return(StatusCode(HttpStatusCode.Forbidden)); } var entityUri = new Uri(key); var entity = LoadEntity(new DefaultAuthenticationProvider(), entityUri); var lifeCycleManager = new LifeCycleManager(null, ExtractTypeFromUriString(key)); lifeCycleManager.Next(entityUri, entity, identity.Tid); return(Ok()); } catch (UriFormatException e) { return(BadRequest("Invalid id (Id should be a valid URI)")); } catch (HttpRequestException e) { return(BadRequest("Loading entity from passed Uri failed (Either not found or not authorized)")); } catch (InvalidOperationException e) { return(BadRequest("Changing state with 'Continue' condition not possible")); } catch (Exception e) { Debug.WriteLine(String.Format("{0}: {1}\r\n{2}", e.Source, e.Message, e.StackTrace)); throw; } }
public async Task<IHttpActionResult> Next([FromODataUri] String key, ODataActionParameters parameters) { var declaringType = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType; var fn = String.Format("{0}:{1}", declaringType.Namespace, declaringType.Name); try { Debug.WriteLine(fn); var identity = CurrentUserDataProvider.GetIdentity(TenantId); var permissionId = CreatePermissionId("CanNext"); if (!identity.Permissions.Contains(permissionId)) { return StatusCode(HttpStatusCode.Forbidden); } var entityUri = new Uri(key); var entity = LoadEntity(new DefaultAuthenticationProvider(), entityUri); var lifeCycleManager = new LifeCycleManager(null, ExtractTypeFromUriString(key)); lifeCycleManager.Next(entityUri, entity, identity.Tid); return Ok(); } catch (UriFormatException e) { return BadRequest("Invalid id (Id should be a valid URI)"); } catch (HttpRequestException e) { return BadRequest("Loading entity from passed Uri failed (Either not found or not authorized)"); } catch (InvalidOperationException e) { return BadRequest("Changing state with 'Continue' condition not possible"); } catch (Exception e) { Debug.WriteLine(String.Format("{0}: {1}\r\n{2}", e.Source, e.Message, e.StackTrace)); throw; } }