// public processDelete static public Task <ActionResult> ProcessDelete <T>(IIdentity user, HttpRequest uriInfo, DbContext entityManager, String serviceName) where T : class { return(RequestFilter.GetObject <T>(user, uriInfo, entityManager, serviceName).ContinueWith <ActionResult>(taskGet => { return DbUtils.DeleteOne <T>(entityManager, taskGet.Result).ContinueWith <ActionResult>((taskObjDeleted) => { RequestFilter.Notify(taskObjDeleted.Result, serviceName, true); return Response.Ok(); }, TaskContinuationOptions.NotOnFaulted).Result; }, TaskContinuationOptions.NotOnFaulted)); }
// public static public Task <ActionResult> ProcessCreate <T>(IIdentity user, DbContext entityManager, String serviceName, T obj) where T : class { ActionResult response = RequestFilter.CheckObjectAccess(user, serviceName, obj); if (response != null) { return(Task.Run(() => response)); } return(DbUtils.Insert <T>(null, entityManager, obj).ContinueWith <ActionResult>(taskInsert => { Object newObj = taskInsert.Result; RequestFilter.Notify(newObj, serviceName, false); return Response.Ok(newObj); }, TaskContinuationOptions.NotOnFaulted)); }
// public processUpdate static public Task <ActionResult> ProcessUpdate <T>(IIdentity user, HttpRequest uriInfo, DbContext entityManager, String serviceName, T obj) where T : class { return(RequestFilter.GetObject <T>(user, uriInfo, entityManager, serviceName).ContinueWith <ActionResult>(taskGet => { ActionResult response = CheckObjectAccess(user, serviceName, obj); if (response != null) { return response; } entityManager.Entry(taskGet.Result).State = EntityState.Detached; return DbUtils.Update <T>(null, entityManager, obj).ContinueWith <ActionResult>(taskNewObj => { RequestFilter.Notify(taskNewObj.Result, serviceName, false); return Response.Ok(taskNewObj.Result); }, TaskContinuationOptions.NotOnFaulted).Result; }, TaskContinuationOptions.NotOnFaulted)); }