コード例 #1
0
        public List <SightingDetails> Get(string uniqueID)
        {
            List <SightingDetails> sightings = new List <SightingDetails>();

            GMPRestApi.Models.Data.GMPMissingPersonEntities entities = new GMPRestApi.Models.Data.GMPMissingPersonEntities();
            var person = entities.misper_.Where(x => x.Unique_ID == uniqueID).FirstOrDefault();

            if (person != null)
            {
                foreach (var location in person.Locations)
                {
                    var             locationType = entities.LocationTypes.Where(x => x.ID == location.LocationTypeID).FirstOrDefault();
                    SightingDetails sighting     = new SightingDetails();
                    sighting.Latitude      = location.Latitude;
                    sighting.Longitude     = location.Longitude;
                    sighting.UserID        = location.Unique_ID;
                    sighting.ContactNumber = location.ContactNumber;
                    sighting.DateTime      = location.SightingDate;
                    sighting.IsVerified    = location.Verified == "Y";
                    sighting.LocationType  = locationType.LocationType1;
                    sightings.Add(sighting);
                }
            }
            return(sightings);
        }
コード例 #2
0
 public void Post([FromBody] Sighting sighting)
 {
     GMPRestApi.Models.Data.GMPMissingPersonEntities entities = new GMPRestApi.Models.Data.GMPMissingPersonEntities();
     Models.Data.misper_ person = entities.misper_.Where(x => x.Unique_ID == sighting.UserID).FirstOrDefault();
     if (person == null)
     {
         throw new HttpException("Person not found");
     }
     else
     {
         var socialMediaType = entities.LocationTypes.Where(x => x.LocationCode == "APSIG").FirstOrDefault();
         var location        = new Models.Data.Location();
         location.Unique_ID      = person.Unique_ID;
         location.ContactNumber  = sighting.ContactNumber;
         location.Latitude       = sighting.Latitude;
         location.LocationTypeID = socialMediaType.ID;
         location.Verified       = "N";
         location.SightingDate   = DateTime.Now;
         entities.Locations.Add(location);
         entities.Locations.AddOrUpdate();
         entities.SaveChanges();
         person.Locations.Add(location);
         var phoneData = new Models.Data.PhoneData();
         location.PhoneDatas.Add(phoneData);
         phoneData.LocationID = location.ID;
         phoneData.DeviceID   = sighting.DeviceID;
         entities.PhoneDatas.AddOrUpdate();
         entities.misper_.AddOrUpdate();
         entities.SaveChanges();
     }
 }
コード例 #3
0
        public List <LocationType> Get()
        {
            List <LocationType> locationTypes = new List <LocationType>();

            GMPRestApi.Models.Data.GMPMissingPersonEntities entities = new GMPRestApi.Models.Data.GMPMissingPersonEntities();
            foreach (var locationType in entities.LocationTypes)
            {
                LocationType locationInfo = new LocationType();
                locationInfo.Id   = locationType.ID;
                locationInfo.Name = locationType.LocationType1;
                locationTypes.Add(locationInfo);
            }
            return(locationTypes);
        }
コード例 #4
0
        public ProfileInfo GetProfileInfo()
        {
            ProfileInfo profileInfo = new ProfileInfo();

            GMPRestApi.Models.Data.GMPMissingPersonEntities entities = new GMPRestApi.Models.Data.GMPMissingPersonEntities();
            var person = entities.misper_.OrderBy(x => x.ID).Take(1);

            profileInfo.MinProfileID = person.FirstOrDefault().ID;

            person = entities.misper_.OrderByDescending(x => x.ID).Take(1);
            profileInfo.MaxProfileID = person.FirstOrDefault().ID;

            return(profileInfo);
        }
コード例 #5
0
 public void Post([FromBody] Sighting sighting, int locationType)
 {
     GMPRestApi.Models.Data.GMPMissingPersonEntities entities = new GMPRestApi.Models.Data.GMPMissingPersonEntities();
     Models.Data.misper_ person = entities.misper_.Where(x => x.Unique_ID == sighting.UserID).FirstOrDefault();
     if (person == null)
     {
         throw new HttpException("Person not found");
     }
     else
     {
         var location = new Models.Data.Location();
         location.Unique_ID      = person.Unique_ID;
         location.ContactNumber  = sighting.ContactNumber;
         location.Latitude       = sighting.Latitude;
         location.LocationTypeID = locationType;
         person.Locations.Add(location);
         entities.Locations.Add(location);
         entities.Locations.AddOrUpdate();
         entities.SaveChanges();
     }
 }