// POST /api/Beacon - check user status and user exists
        public async Task<UserDataModel> PostBeaconDataAsync(UserDataModel user, BeaconDataModel beacon)
        {
            string url = AppConstants.ApiBaseUrl + "/Beacon";

            // TODO PostBeaconDataModel implementationa
            PostBeaconDataModel postBeaconDataModel = new PostBeaconDataModel();
            postBeaconDataModel.BeaconUuid = beacon.BeaconUuid;
            postBeaconDataModel.Count = beacon.Count;
            postBeaconDataModel.Distance = beacon.Distance;
            postBeaconDataModel.ElaspedTime = beacon.ElaspedTime;
            postBeaconDataModel.FirstDetectTime = beacon.FirstDetectTime;
            postBeaconDataModel.LastDetectTime = beacon.LastDetectTime;
            postBeaconDataModel.Major = beacon.Major;
            postBeaconDataModel.Minor = beacon.Minor;
            postBeaconDataModel.Rssi = beacon.Rssi;
            postBeaconDataModel.TXPower = beacon.TXPower;
            postBeaconDataModel.KeyTime = beacon.KeyTime;
            postBeaconDataModel.Id = beacon.Id;
            postBeaconDataModel.UserMajor = user.Major;
            postBeaconDataModel.UserMinor = user.Minor;
            postBeaconDataModel.UserUuid = user.UserUuid;

            HttpContent content = new StringContent(Utils.SerializeToJson(postBeaconDataModel), Encoding.UTF8, "application/json");
            var result = await Post(url, content);
            if (result != null)
            {
                return Utils.DeserializeFromJson<UserDataModel>(result);
            }
            return null;
        }
Example #2
0
        // POST /api/Beacon - check user status and user exists
        public async Task <bool> PostBeaconDataAsync(UserDataModel user, BeaconDataModel beacon)
        {
            string url = AppConstants.ApiBaseUrl + "/Beacon";

            // TODO PostBeaconDataModel implementationa
            PostBeaconDataModel postBeaconDataModel = new PostBeaconDataModel();

            postBeaconDataModel.BeaconUuid      = beacon.BeaconUuid;
            postBeaconDataModel.Count           = beacon.Count;
            postBeaconDataModel.Distance        = beacon.Distance;
            postBeaconDataModel.ElaspedTime     = beacon.ElaspedTime;
            postBeaconDataModel.FirstDetectTime = beacon.FirstDetectTime;
            postBeaconDataModel.LastDetectTime  = beacon.LastDetectTime;
            postBeaconDataModel.Major           = beacon.Major;
            postBeaconDataModel.Minor           = beacon.Minor;
            postBeaconDataModel.Rssi            = beacon.Rssi;
            postBeaconDataModel.TXPower         = beacon.TXPower;
            postBeaconDataModel.KeyTime         = beacon.KeyTime;
            postBeaconDataModel.Id        = beacon.Id;
            postBeaconDataModel.UserMajor = user.Major;
            postBeaconDataModel.UserMinor = user.Minor;
            postBeaconDataModel.UserUuid  = user.UserUuid;

            HttpContent content = new StringContent(Utils.SerializeToJson(postBeaconDataModel), Encoding.UTF8, "application/json");

            try
            {
                HttpResponseMessage result = await httpClient.PostAsync(url, content);

                await result.Content.ReadAsStringAsync();

                if (result.IsSuccessStatusCode)
                {
                    return(true);
                }
            }
            catch { }
            return(false);
        }