Ejemplo n.º 1
0
        public IHttpActionResult AllPins(pinTime time)
        {
            Reply            reply   = new Reply();
            List <SinglePin> PinList = new List <SinglePin>();
            List <Pin>       pins;

            if (time.Time == null)
            {
                pins = db.Pin.OrderBy(s => s.Time).ToList();
            }
            else
            {
                pins = db.Pin.Where(s => s.Time > time.Time).OrderBy(s => s.Time).ToList();
            }

            if (pins == null)
            {
                return(NotFound());
            }

            foreach (Pin thePin in pins)
            {
                SinglePin single = getPin(thePin);
                PinList.Add(single);
            }
            reply.result = "success";
            reply.data   = JsonConvert.SerializeObject(PinList);
            return(Ok(reply));
        }
Ejemplo n.º 2
0
        //Find a single pin.
        public SinglePin getPin(Pin thePin)
        {
            SinglePin   result  = new SinglePin();
            PinRetrieve thisPin = new PinRetrieve();

            thisPin.PinId    = thePin.PinId;
            thisPin.Time     = thePin.Time;
            thisPin.CoordLat = thePin.CoordLat;
            thisPin.CoordLog = thePin.CoordLog;
            //Find descriptions of StreetLight, CCTV and ExperienceType
            var theStreetLight = db.StreetLight.Find(thePin.StreetLightId);

            thisPin.StreetLight = theStreetLight.Description;
            var theCCTV = db.CCTV.Find(thePin.CCTVId);

            thisPin.CCTV = theCCTV.Description;
            var theType = db.ExperienceType.Find(thePin.ExperienceTypeId);

            thisPin.ExperienceType   = theType.Description;
            thisPin.Experience       = thePin.Experience;
            thisPin.OtherDetails     = thePin.OtherDetails;
            thisPin.UserProfileId    = thePin.UserProfileId;
            thisPin.State            = thePin.State;
            thisPin.Street           = thePin.Street;
            thisPin.SuburbSuburbName = thePin.SuburbSuburbName;
            result.pinDetails        = thisPin;
            return(result);
        }
Ejemplo n.º 3
0
        public IHttpActionResult Retrieve()
        {
            Reply            reply   = new Reply();
            String           json    = "";
            List <SinglePin> PinList = new List <SinglePin>();
            var        userID        = User.Identity.GetUserId();
            List <Pin> pins          = db.Pin.Where(s => s.UserProfileId == userID).ToList();

            if (pins == null)
            {
                return(NotFound());
            }

            foreach (Pin thePin in pins)
            {
                SinglePin single = getPin(thePin);
                PinList.Add(single);
            }
            reply.result = "success";
            reply.data   = JsonConvert.SerializeObject(PinList);
            return(Ok(reply));
        }