public async Task <CommunicationResponse> UnsbscibePushNotification(DeviceRegistrationRequest Request) { try { var DeviceStore = new DeviceStore(); DeviceStore = _dbContext.Set <DeviceStore>().SingleOrDefault(e => e.UserID == Request.UserID); DeviceStore.InActive(); _MessageRepository.Update(DeviceStore); return(await Task.FromResult(new CommunicationResponse { ReturnCode = enResponseCode.Success, ReturnMsg = EnResponseMessage.PushNotificationunsubscriptionSuccess, ErrorCode = enErrorCode.PushNotificationunsubscriptionSuccess })); } catch (Exception ex) { return(await Task.FromResult(new CommunicationResponse { ReturnCode = enResponseCode.InternalError, ReturnMsg = EnResponseMessage.PushNotificationUnsubscriptionFail, ErrorCode = enErrorCode.PushNotificationUnsubscriptionFail })); } }
protected void InitStore(ModBusSlaveTcpConfig config) { lock (_lock) { ModBus.Logger .LogDebug($"Creating device store with {String.Join(",", config.DeviceIds)} devices"); foreach (var dev in config.DeviceIds) { DeviceStore.Add(dev, new ModBusSlaveStore(dev)); } } }
public async Task <CommunicationResponse> SubscibePushNotification(DeviceRegistrationRequest Request) { try { var DeviceStore = new DeviceStore(); DeviceStore = _dbContext.Set <DeviceStore>().SingleOrDefault(e => e.UserID == Request.UserID); if (DeviceStore != null && DeviceStore.UserID > 0) { DeviceStore.Active(); _MessageRepository.Update(DeviceStore); } else { DeviceStore = new DeviceStore() { DeviceID = Request.DeviceID, UserID = Request.UserID, Status = Convert.ToInt16(ServiceStatus.Active), CreatedBy = 1, CreatedDate = DateTime.UtcNow }; _MessageRepository.Add(DeviceStore); } return(await Task.FromResult(new CommunicationResponse { ReturnCode = enResponseCode.Success, ReturnMsg = EnResponseMessage.PushNotificationSubscriptionSuccess, ErrorCode = enErrorCode.PushNotificationSubscriptionSuccess })); } catch (Exception ex) { return(await Task.FromResult(new CommunicationResponse { ReturnCode = enResponseCode.InternalError, ReturnMsg = EnResponseMessage.PushNotificationSubscriptionFail, ErrorCode = enErrorCode.PushNotificationSubscriptionFail })); } }