internal Response updateOrderState(Order order, params Input[] inputs) { Response response = new Response(); Input state = inputs.Where(input => input.Name == "state").ElementAt(0); if (state == null || state.Value == "") response.Errors.Add(new Error("Order state can't be empty.")); if (!order.isAllowableState(state.Value)) response.Errors.Add(new Error("Order state " + state.Value + " isn't acceptable.")); if (response.Errors.Count > 0) response.State = ResponseState.FAIL; else { order.State = state.Value; bool orderUpdated = order.update(); if (orderUpdated) response.State = ResponseState.SUCCESS; else { response.Errors.Add(new Error("Unknown Error Happened While Updating Order State.")); response.State = ResponseState.FAIL; } } return response; }