public HttpResponseMessage Operations(string toid, string op, [FromBody] TaskInfo task, string result = "", string message = "") { Guid oid; if (!Guid.TryParse(toid, out oid)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } try { if (op.Equals(TaskOperation.Assign.ToString(), StringComparison.OrdinalIgnoreCase)) { TasksService.AssignTaskTo(new AssignTaskToRequest { User = task.AcceptedBy, TaskOid = oid }); } else if (op.Equals(TaskOperation.Complete.ToString(), StringComparison.OrdinalIgnoreCase)) { TasksService.CompleteTask(new CompleteTaskRequest { TaskId = toid, User = task.AcceptedBy, Result = result }); } else if (op.Equals(TaskOperation.GiveBack.ToString(), StringComparison.OrdinalIgnoreCase)) { TasksService.GiveBackTask(new GiveBackTaskRequest { TaskOid = oid }); } else if (op.Equals(TaskOperation.Approve.ToString(), StringComparison.OrdinalIgnoreCase)) { var properties = TasksService.GetPropertiesForTask(new GetPropertiesForTaskRequest { TaskOid = Guid.Parse(toid) }); var taskFromDb = TasksService.GetTask(new GetTaskRequest { TaskOid = Guid.Parse(toid) }); // Do I need this? // If this is necessary think of notification /* * TasksService.AddTraceToWorkflow(new AddTraceToWorkflowRequest * { * WorkflowOid = taskFromDb.Task.WorkflowOid.ToString(), * TaskOid = toid, * User = task.AcceptedBy, * Message = message * }); */ TasksService.ApproveTask(new ApproveTaskRequest { TaskId = toid, CorrelationId = taskFromDb.Task.TaskCorrelationId, TaskCode = taskFromDb.Task.TaskCode, Result = result, UserName = task.AcceptedBy, WorkflowId = taskFromDb.Task.WorkflowOid.ToString(), Parameters = new PropertyInfos(properties.Properties) }); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } return(Request.CreateResponse(HttpStatusCode.OK)); }