private async Task <CellularActionUpdateResponseModel> processActionRequests(DeviceModel device, List <CellularActionModel> actions) { var iccid = device.SystemProperties.ICCID; var terminal = _cellularExtensions.GetSingleTerminalDetails(new Iccid(iccid)); var completedActions = new List <CellularActionModel>(); var failedActions = new List <CellularActionModel>(); var exceptions = new List <ErrorModel>(); foreach (var action in actions) { var success = false; try { switch (action.Type) { case CellularActionType.UpdateStatus: success = _cellularExtensions.UpdateSimState(iccid, action.Value); break; case CellularActionType.UpdateSubscriptionPackage: success = _cellularExtensions.UpdateSubscriptionPackage(iccid, action.Value); break; case CellularActionType.UpdateLocale: success = _cellularExtensions.SetLocale(iccid, action.Value); break; case CellularActionType.ReconnectDevice: success = _cellularExtensions.ReconnectDevice(iccid); break; case CellularActionType.SendSms: success = await _cellularExtensions.SendSms(iccid, action.Value); break; default: failedActions.Add(action); break; } } catch (Exception exception) { success = false; exceptions.Add(new ErrorModel(exception)); } if (!success) { failedActions.Add(action); } else { completedActions.Add(action); } } return(new CellularActionUpdateResponseModel() { CompletedActions = completedActions, FailedActions = failedActions, Exceptions = exceptions }); }