コード例 #1
0
ファイル: ImageService.cs プロジェクト: jamckelvey/BlueRidge
        public ImageResponse Delete(ImageUpdate request)
        {
            var response = new ImageResponse();
            using (_dbSession)
            {
                try
                {
                    // Remove all links from containers
                    IEnumerable<Container> containers = _dbSession.Query<Container>();

                    foreach (Container container in containers)
                    {
                        RemoveImageFromContainer(container, request.ImageUrl);
                    }

                    // Delete the image itself
                    _imageSession.Delete(request.ImageUrl);
                    _dbSession.SaveChanges();
                    response.ImageUrl = request.ImageUrl;
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Delete(ImageUpdate): {0}", ex.Message);
                    throw;
                }
            }

            return response;
        }
コード例 #2
0
ファイル: ImageService.cs プロジェクト: jamckelvey/BlueRidge
        public ImageResponse Post(ImageUpload request)
        {
            var response = new ImageResponse();
            using (_dbSession)
            {
                try
                {
                    var parts = Request.PathInfo.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);

                    string fileLocation = _imageSession.Save(request.RequestStream, parts[1]);
                    response.ImageUrl = fileLocation;

                    _dbSession.SaveChanges();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Post(ImageUpload): {0}", ex.Message);
                    throw;
                }
            }

            return response;
        }