public ShapeConfigViewModel GetShapeConfig(Guid id) { string result = _serviceApi.CallGetApi($"{_urlShapeConfigApi}/{id}"); ShapeConfigViewModel resultObject = JsonConvert.DeserializeObject <ShapeConfigViewModel>(result); return(resultObject); }
public IActionResult Details(Guid id) { ShapeConfigViewModel result = _serviceApi.GetShapeConfig(id); if (result != null) { return(View(result)); } else { return(NotFound()); } }
public ShapeConfigViewModel CreateShapeConfig(ShapeConfigCreateModel newRepositoryConfigView) { Guid guidAdded; string parameters = $"?name={newRepositoryConfigView.Name}&repositoryID={newRepositoryConfigView.RepositoryID}"; string result = _serviceApi.CallPostApi($"{_urlShapeConfigApi}{parameters}", newRepositoryConfigView.ShapeFile, true); result = JsonConvert.DeserializeObject <string>(result); Guid.TryParse(result, out guidAdded); result = _serviceApi.CallGetApi($"{_urlShapeConfigApi}/{guidAdded}"); ShapeConfigViewModel resultObject = JsonConvert.DeserializeObject <ShapeConfigViewModel>(result); return(resultObject); }
public IActionResult DownloadShape(Guid id) { ShapeConfigViewModel result = _serviceApi.GetShapeConfig(id); if (result != null) { var content = new System.IO.MemoryStream(Encoding.ASCII.GetBytes(result.Shape)); var contentType = "APPLICATION/octet-stream"; var fileName = $"{id}_shape.txt"; return(File(content, contentType, fileName)); } else { return(NotFound()); } }
public IActionResult Edit(Guid id) { ShapeConfigViewModel result = _serviceApi.GetShapeConfig(id); if (result != null) { ShapeConfigEditModel shapeConfigViewModel = new ShapeConfigEditModel() { Name = result.Name, RepositoryID = result.RepositoryID, Shape = result.Shape, ShapeConfigID = result.ShapeConfigID }; return(View(shapeConfigViewModel)); } else { return(NotFound()); } }
public IActionResult Create(ShapeConfigCreateModel shapeConfigViewModel)/*Guid ShapeConfigID,string Name, Guid RepositoryID, IFormFile ShapeFile)*/ { try { var repository = _repositoryServiceApi.GetRepositoryConfig(shapeConfigViewModel.RepositoryID); if (repository == null) { ModelState.AddModelError("RepositoryID", "No existe el repositorio"); return(View("Create", shapeConfigViewModel)); } else { ShapeConfigViewModel result = _serviceApi.CreateShapeConfig(shapeConfigViewModel); return(RedirectToAction("Details", new { id = result.ShapeConfigID })); } } catch (BadRequestException) { return(BadRequest()); } }