Beispiel #1
0
        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([FromBody] CreateArtifactModel createArtifactModel)
        {
            if (ModelState.IsValid)
            {
                var artifactId = await _artifactService.CreateArtifact(createArtifactModel).ConfigureAwait(false);

                if (artifactId != -1)
                {
                    return(Created("", $"{Request.GetDisplayUrl()}/{artifactId}"));
                }
                return(BadRequest("Something went wrong !"));
            }
            return(BadRequest("Something went wrong !"));
        }
Beispiel #3
0
        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());
            }
        }
Beispiel #4
0
        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());
            }
        }