Beispiel #1
0
        public UpdateDeviceTokenResponse UpdatePushToken(UpdateDeviceTokenRequest userRequest)
        {
            UpdateDeviceTokenResponse updateTokenResponse = new UpdateDeviceTokenResponse();

            updateTokenResponse.IsSuccess = false;
            updateTokenResponse.Message   = "Update device push token unsuccessful";
            try
            {
                if (!string.IsNullOrEmpty(userRequest.AuthToken) &&
                    !string.IsNullOrEmpty(userRequest.DevicePushToken) &&
                    !string.IsNullOrEmpty(userRequest.DeviceType)
                    )
                {
                    UserEL userPushData = new UserEL();
                    userPushData.DeviceID   = userRequest.DevicePushToken;
                    userPushData.DeviceType = userRequest.DeviceType;
                    userPushData.AuthToken  = userRequest.AuthToken;
                    userHelper.UpdateUserToken(userPushData);
                }
                else
                {
                    updateTokenResponse.Message = "Please pass value of all mandatory fields";
                }
            }
            catch (Exception ex)
            {
                updateTokenResponse.Message = "An error occurred while update device push token.";
            }
            return(updateTokenResponse);
        }
Beispiel #2
0
        public UpdateDeviceTokenResponse UpdatePushToken(UpdateDeviceTokenRequest userRequest)
        {
            UpdateDeviceTokenResponse updateTokenResponse = new UpdateDeviceTokenResponse();

            updateTokenResponse.IsSuccess = false;
            updateTokenResponse.Message   = "Update device push token unsuccessful";
            try
            {
                if (!string.IsNullOrEmpty(userRequest.AuthToken) &&
                    !string.IsNullOrEmpty(userRequest.DevicePushToken) &&
                    !string.IsNullOrEmpty(userRequest.DeviceType)
                    )
                {
                    AuthenticationToken authToken = new Helper().GetAuthenticationToken(userRequest.AuthToken);

                    if (authToken != null)
                    {
                        using (uow = new UnitOfWork())
                        {
                            User existingUser = null;

                            existingUser = uow.UserRepository.Get().Where(u => u.UserID.Equals(authToken.FkUserID)).FirstOrDefault();

                            #region Get Existing User

                            if (existingUser != null)
                            {
                                existingUser.PushToken  = userRequest.DevicePushToken;
                                existingUser.DeviceType = userRequest.DeviceType;
                                uow.UserRepository.Update(existingUser);
                                uow.Save();

                                updateTokenResponse.IsSuccess = true;
                                updateTokenResponse.Message   = "Update device push token successfully";
                            }
                            else
                            {
                                updateTokenResponse.Message = "User not found";
                            }


                            #endregion
                        }
                    }
                    else
                    {
                        updateTokenResponse.Message = "Unauthorizes user";
                    }
                }
                else
                {
                    updateTokenResponse.Message = "Please pass value of all mandatory fields";
                }
            }
            catch (Exception ex)
            {
                updateTokenResponse.Message = "An error occurred while update device push token.";
            }
            return(updateTokenResponse);
        }