public async Task CreateArtifact(CreateArtifactDTO input) { var artifact = _mapper.Map <Artifact>(input); artifact.RoomId = input.RoomId; artifact.LocationId = input.LocationId; await _artifactRepository.Create(artifact); }
public async Task <IActionResult> CreateArtifact(CreateArtifactDTO input) { try { await _artifactService.CreateArtifact(input); return(Ok()); } catch (System.Exception e) { throw e; } }
public async Task <IActionResult> CreateArtifact(CreateArtifactViewModel input) { string imagesLocation = "/Images/"; string fileName = ""; try { var path = ""; if (input.File != null) { fileName = Path.GetFileName(input.File.FileName); // this should yield something like: // c:\inetpub\yourappname\wwwroot\images\image-file-name.png path = Path.Combine(hostingEnvironment.WebRootPath, "Images", fileName); using (var fs = System.IO.File.Open(path, FileMode.Create)) { input.File.OpenReadStream().CopyTo(fs); fs.Flush(); } } //string url =_blobManager.UploadImageAsBlob(input.File); CreateArtifactDTO data = new CreateArtifactDTO() { Name = input.Name, MainImageURL = imagesLocation + fileName, RoomId = input.RoomId, LocationId = input.LocationId }; await _artifactService.CreateArtifact(data); return(Ok()); } catch (Exception) { return(BadRequest()); } }
public async Task <IActionResult> CreateArtifact(CreateArtifactViewModel input) { try { string url = await _blobManager.UploadImageAsBlob(input.File); CreateArtifactDTO data = new CreateArtifactDTO() { Name = input.Name, MainImageURL = url, RoomId = input.RoomId, LocationId = input.LocationId }; await _artifactService.CreateArtifact(data); return(Ok()); } catch (Exception) { return(BadRequest()); } }