Esempio n. 1
0
        public List <PointDetailVM> GetPoints()
        {
            Console.WriteLine("jhh");
            var points = _points.Find(x => true).ToList();

            Console.WriteLine("jhh");
            if (points != null)
            {
                List <PointDetailVM> result = new List <PointDetailVM>();

                foreach (var item in points)
                {
                    var temp = new PointDetailVM()
                    {
                        PointId      = item.PointId.ToString(),
                        NameLocation = item.NameLocation,
                        Address      = item.Address,
                        CityName     = _cityReporitory.GetNameCityById(item.CityId),
                        Lat          = item.Lat,
                        Lng          = item.Lng
                    };

                    result.Add(temp);
                }
                return(result);
            }
            return(null);
        }
Esempio n. 2
0
 public ActionResult UpdatePoint([FromBody] PointDetailVM point, string id)
 {
     if (ModelState.IsValid)
     {
         _pointRepository.UpdatePoint(point, Guid.Parse(id));
         return(Ok());
     }
     return(BadRequest());
 }
Esempio n. 3
0
        public void UpdatePoint(PointDetailVM pointVM, Guid id)
        {
            var point = _mapper.Map <Point>(pointVM);
            var city  = _cityReporitory.GetCityDetailbyName(pointVM.CityName);

            if (city != null)
            {
                point.CityId = Guid.Parse(city.CityId);
                Console.WriteLine(point);
                _points.ReplaceOne(p => p.PointId.Equals(id), point);
            }
        }
Esempio n. 4
0
        public async Task <ActionResult> registerDevice([FromBody] PointDetailVM point)
        {
            var result = _pointRepository.AddPoint(point);

            if (result.PointId != null)
            {
                var ibmDevice = await _IBMClientHelper.registerDevice(result.PointId.ToString());

                return(Ok(new { point = result, ibmResult = ibmDevice }));
            }

            return(BadRequest());
        }
Esempio n. 5
0
        public Point AddPoint(PointDetailVM pointVM)
        {
            var point = _mapper.Map <Point>(pointVM);
            var city  = _cityReporitory.GetCityDetailbyName(pointVM.CityName);

            if (city != null)
            {
                point.CityId = Guid.Parse(city.CityId);
                _points.InsertOne(point);
                return(point);
            }
            return(null);
        }
Esempio n. 6
0
        public ActionResult <Point> AddPoint([FromBody] PointDetailVM point)
        {
            if (ModelState.IsValid)
            {
                var result = _pointRepository.AddPoint(point);

                if (result == null)
                {
                    return(NoContent());
                }
                return(Ok(result));
            }
            return(BadRequest());
        }
Esempio n. 7
0
 public ActionResult updateDevice([FromBody] PointDetailVM point, string id)
 {
     _pointRepository.UpdatePoint(point, new Guid(id));
     return(Ok());
 }