コード例 #1
0
        public Map CreateMap(Map map)
        {
            map.CreateDate = DateTime.Now;
            int id = _mapRepository.Create(map);

            return(_mapRepository.GetById(id));
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        private async Task ReferencialIntegrityCheckMap(Video entity)
        {
            var maps = await _mapRepository.GetById(entity.MapId);

            if (maps == null)
            {
                throw new InvalidOperationException(Messages.MAPA_EXISTENTE);
            }
        }
コード例 #6
0
        public IActionResult Get(string id)
        {
            var item = _maps.GetById(id);

            if (item == null)
            {
                return(NotFound());
            }
            else
            {
                return(new ObjectResult(item));
            }
        }
コード例 #7
0
 public async Task <Map> GetById(int id)
 {
     return(await _mapRepository.GetById(id));
 }