Ejemplo n.º 1
0
        public async Task<HttpResponseMessage> Post(FileModel model)
        {
            var userFile = new DomainUserFile
            {
                Created = DateTime.UtcNow,
                Modified = DateTime.UtcNow,
                UserId = UserId,
                FileUri = model.File.Uri,
                ContentType = model.File.ContentType,
                FileLength = model.File.Length,
                FileName = model.Name
            };

            userFile = await _userFileRepository.AddAsync(userFile);

            var file = new File
            {
                ContentType = userFile.ContentType,
                Name = userFile.FileName,
                Uri = userFile.FileUri,
                Id = userFile.FileId,
                Length = userFile.FileLength
            };

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, file);
            response.SetLastModifiedDate(userFile.Modified);

            return response;
        }
Ejemplo n.º 2
0
        public async Task<HttpResponseMessage> Put([FromUri] string id, FileModel model)
        {
            var userFile = new DomainUserFile
            {
                UserId = UserId,
                ContentType = model.File.ContentType,
                FileId = id,
                FileUri = model.File.Uri,
                FileLength = model.File.Length,
                FileName = model.Name
            };

            userFile = await _userFileRepository.EditAsync(userFile);

            var file = new File
            {
                ContentType = userFile.ContentType,
                Name = userFile.FileName,
                Uri = userFile.FileUri,
                Length = userFile.FileLength
            };

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, file);
            response.SetLastModifiedDate(userFile.Modified);

            return response;
        }