public async Task <IActionResult> PostAttachment([FromForm] FileFormData model)
        {
            //Validate the Model
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Boolean isUploaded = false;

            //Check if the file is not empty
            if (model.File.Length > 0)
            {
                Stream         stream      = model.File.OpenReadStream();
                string         contentType = model.File.ContentType;
                BlobProperties properties  = new BlobProperties
                {
                    ContentType = contentType,
                    Security    = BlobSecurity.Public
                };
                string blobContainer = model.ParentItem.ToString();
                string blobName      = Path.GetRandomFileName();
                isUploaded = await _provider.UploadBlobAsync(blobContainer, blobName, stream, properties);

                //store the data
                var attachment = new Attachment()
                {
                    UploadedBy    = model.UploadedBy,
                    ParentItem    = model.ParentItem,
                    FileName      = model.File.FileName,
                    Size          = model.File.Length,
                    BlobContainer = blobContainer,
                    BlobName      = blobName,
                    UploadedOn    = DateTime.UtcNow
                };
                _context.attachments.Add(attachment);


                if (isUploaded)
                {
                    await _context.SaveChangesAsync();

                    return(Created(nameof(AttachmentController), new AttachmentDTO()
                    {
                        Id = attachment.Id,
                        FileName = attachment.FileName,
                        Size = attachment.Size,
                        UploadedBy = attachment.UploadedBy,
                        UploadedOn = attachment.UploadedOn
                    }));
                }
            }

            ModelState.AddModelError("File", $"The request couldn't be processed (Error 20).");
            // Log error
            return(BadRequest(ModelState));
        }
        public async Task CreateRequestForCommandAsync <T>(Guid id)
        {
            var exists = await ExistAsync(id);

            var request = exists ?
                          throw new AttachmentDomainException($"Request with {id} already exists") :
                                new ClientRequest()
                                {
                                    Id   = id,
                                    Name = typeof(T).Name,
                                    Time = DateTime.UtcNow
                                };

            _context.Add(request);

            await _context.SaveChangesAsync();
        }