public Map CreateMap(Map map) { map.CreateDate = DateTime.Now; int id = _mapRepository.Create(map); return(_mapRepository.GetById(id)); }
public void Post(string mapId, [FromBody] Node node) { if (!ModelState.IsValid) { HttpContext.Response.StatusCode = 400; } else { var map = _maps.GetById(mapId); if (map == null) { HttpContext.Response.StatusCode = 404; } else { map.AddNode(node); _maps.Update(map); } // var url = Url.RouteUrl("GetMapById", new {id = map.Id}, Request.Scheme, // Request.Host.ToUriComponent()); // HttpContext.Response.StatusCode = 201; // HttpContext.Response.Headers["Location"] = url; } }
public JsonResult Select(int id) { var map = _mapRepository.GetById(id); if (map == null) { return(Json(new { success = false, messages = new string[] { "El mapa seleccionado no existe" } }, JsonRequestBehavior.AllowGet)); } _mapRepository.ChangeSelected(id); return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> GetPath(string id, string start, string end) { if (string.IsNullOrEmpty(start) || string.IsNullOrEmpty(end)) { return(BadRequest("'start' and/or 'end' parameters are required but missing")); } var map = await _mapRepository.GetById(id); if (map == null) { return(NotFound($"Map with id '{id}' was not found")); } var path = _pathAlgorithm.Find(map, start, end); if (path == null) { return(Content("null", "application/json")); // Ok(null) would result in 204 No Content which may be more correct but doesn't comply with the specs. } var result = ToResultDto(path); return(Ok(result)); }
private async Task ReferencialIntegrityCheckMap(Video entity) { var maps = await _mapRepository.GetById(entity.MapId); if (maps == null) { throw new InvalidOperationException(Messages.MAPA_EXISTENTE); } }
public IActionResult Get(string id) { var item = _maps.GetById(id); if (item == null) { return(NotFound()); } else { return(new ObjectResult(item)); } }
public async Task <Map> GetById(int id) { return(await _mapRepository.GetById(id)); }