public static async Task <ReturnResult> VerifyDevice(IDeviceAuth device, IUserInfo userInfoContext, string location, IBot botContext) { UserInfo userInfo; var usersInfo = await userInfoContext.Get(device.CurrentDeviceName(), device.GetCurrentUserIp()); if (usersInfo == null || !usersInfo.UserLocation.Equals(location)) { var deviceAuth = device.GetDeviceDetails(); if (deviceAuth.Client != null && deviceAuth.OsInfo != null) { // future upgrade use for notification if the device location differs userInfo = new UserInfo { BrowserId = device.GetBrowserId(), DeviceName = device.CurrentDeviceName(), OsName = deviceAuth.OsInfo.Name, OsPlatForm = deviceAuth.OsInfo.PlatForm, OsSuccess = deviceAuth.OsInfo.Success, OsVersion = deviceAuth.OsInfo.Version, OsShortName = deviceAuth.OsInfo.ShortName, UserIpHost = device.GetCurrentUserIp(), UserLocation = device.GetUserLocation(location), }; var result = await userInfoContext.Add(userInfo); if (result.Succeeded) { return(new ReturnResult { Succeeded = true }); } } else { BotInfo bot = new BotInfo(); bot.Category = deviceAuth.Bot.Category; bot.Name = deviceAuth.Bot.Name; bot.Producer = deviceAuth.Bot.Producer; bot.ProducerUrl = deviceAuth.Bot.ProducerUrl; bot.Url = deviceAuth.Bot.Url; bot.Success = deviceAuth.Bot.Success; var result = await botContext.Add(bot); if (result.Succeeded) { return(new ReturnResult { Succeeded = true }); } } } return(new ReturnResult { Succeeded = false, Error = "verification failed" }); }