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); }
public ActionResult UpdatePoint([FromBody] PointDetailVM point, string id) { if (ModelState.IsValid) { _pointRepository.UpdatePoint(point, Guid.Parse(id)); return(Ok()); } return(BadRequest()); }
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); } }
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()); }
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); }
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()); }
public ActionResult updateDevice([FromBody] PointDetailVM point, string id) { _pointRepository.UpdatePoint(point, new Guid(id)); return(Ok()); }