public SendInfo RetrieveSettings(SettingsRetrieveDTO settingsDTO)
        {
            TokenInfo tokenInfo = new TokenInfo()
            {
                access_token = settingsDTO.accessToken,
                expires_in = settingsDTO.expiresIn,
                token_type = settingsDTO.tokenType,
                scope = settingsDTO.scope,
                refresh_token = settingsDTO.refreshToken
            };

            SendInfo info = GetUserSettings(tokenInfo);
            info.LastWeatherUpdate = null;

            return info;
        }
Example #2
0
        public SendInfo RetrieveSettings(SettingsRetrieveDTO settingsDTO)
        {
            TokenInfo tokenInfo = new TokenInfo()
            {
                access_token  = settingsDTO.accessToken,
                expires_in    = settingsDTO.expiresIn,
                token_type    = settingsDTO.tokenType,
                scope         = settingsDTO.scope,
                refresh_token = settingsDTO.refreshToken
            };

            SendInfo info = GetUserSettings(tokenInfo);

            info.LastWeatherUpdate = null;

            return(info);
        }
        public string DeviceTokenSetting(SettingsRetrieveDTO settingsDTO, long userId)
        {
            try
            {
                if (settingsDTO.sendPush == true && settingsDTO.newDeviceToken != null && settingsDTO.oldDeviceToken == null)
                {
                    ProcessSubscribe(settingsDTO.newDeviceToken, settingsDTO.deviceType, settingsDTO.accessToken, settingsDTO.applicationId);
                    logger.InfoFormat("Device token {0} successfully subscribed", settingsDTO.newDeviceToken);
                    return string.Format("Device token {0} successfully subscribed", settingsDTO.newDeviceToken);
                }
                else if (settingsDTO.sendPush == true && settingsDTO.newDeviceToken != null && settingsDTO.oldDeviceToken != null)
                {
                    return ProcessUpdate(settingsDTO.oldDeviceToken, settingsDTO.newDeviceToken, userId, settingsDTO.deviceType, settingsDTO.applicationId);
                }

                return "Settings successfully retrieved";
            }
            catch (Exception e)
            {
                throw new ApplicationException(e.Message);
            }
        }
Example #4
0
        public string DeviceTokenSetting(SettingsRetrieveDTO settingsDTO, long userId)
        {
            try
            {
                if (settingsDTO.sendPush == true && settingsDTO.newDeviceToken != null && settingsDTO.oldDeviceToken == null)
                {
                    ProcessSubscribe(settingsDTO.newDeviceToken, settingsDTO.deviceType, settingsDTO.accessToken, settingsDTO.applicationId);
                    logger.InfoFormat("Device token {0} successfully subscribed", settingsDTO.newDeviceToken);
                    return(string.Format("Device token {0} successfully subscribed", settingsDTO.newDeviceToken));
                }
                else if (settingsDTO.sendPush == true && settingsDTO.newDeviceToken != null && settingsDTO.oldDeviceToken != null)
                {
                    return(ProcessUpdate(settingsDTO.oldDeviceToken, settingsDTO.newDeviceToken, userId, settingsDTO.deviceType, settingsDTO.applicationId));
                }

                return("Settings successfully retrieved");
            }
            catch (Exception e)
            {
                throw new ApplicationException(e.Message);
            }
        }
        public JsonResult RetrieveUserSettings(SettingsRetrieveDTO settingsDTO)
        {
            GenericResponse responseObj = null;
            int timeStart = DateTime.Now.TimeOfDay.Seconds;
            SendInfo info = null;

            try
            {
                info = settingsService.RetrieveSettings(settingsDTO);

                string message = settingsService.DeviceTokenSetting(settingsDTO, info.Id);

                responseObj = new GenericResponse()
                {
                    Status = 0,
                    ResponseTime = DateTime.Now.TimeOfDay.Seconds - timeStart,
                    Message = message,
                    Data = info,
                };

                return Json(responseObj, JsonRequestBehavior.AllowGet);
            }
            catch (Exception e)
            {
                responseObj = new GenericResponse()
                {
                    Status = 1,
                    ResponseTime = DateTime.Now.TimeOfDay.Seconds - timeStart,
                    Message = e.Message,
                    Data = info,
                };

                ResponseLogging(responseObj);
                return Json(responseObj, JsonRequestBehavior.AllowGet);
            }
        }