public async Task <string> PutLocation(WebModels.LocationModel location) { DataModels.Location dataLocation = location.GetDataModel(); StringContent sc = new StringContent(JsonConvert.SerializeObject(dataLocation), System.Text.Encoding.UTF8, "application/json"); HttpResponseMessage response = await PUT(sc, Constants.ENDPOINT_POST_LOCATION).ConfigureAwait(false); string result = await response.Content.ReadAsStringAsync(); return(result); }
public async Task <WebModels.LocationModel> GetLocationDetails(int locationId) { string url = Constants.ENDPOINT_GET_LOCATION_DETAILS + "/" + locationId.ToString(); HttpResponseMessage response = await GET(url); var result = await response.Content.ReadAsStringAsync(); DataModels.Location dataLocation = JsonConvert.DeserializeObject <DataModels.Location>(result); WebModels.LocationModel webLocation = new WebModels.LocationModel(dataLocation); return(webLocation); }
public bool AddLocation(int userId, string addressName) { try { Location temp = new Location() { AddressName = addressName, UserId = userId }; DB.Locations.Add(temp); var count = DB.SaveChanges(); return count > 0 ? true : false; } catch (Exception e) { Logger.Error("LocationRepository-AddLocation:Error:" + e); throw; } }