Пример #1
0
        public Canvas CreateCanvas(String name)
        {
            if (databaseContext.Canvases.Find(name) != null)
            {
                BadRequest("A canvas with this name already exists");
            }

            Canvas newCanvas = new Canvas();

            newCanvas.Name    = name;
            newCanvas.Version = 1;
            databaseContext.Canvases.Add(newCanvas);
            databaseContext.SaveChanges();

            CanvasImage canvasImage = new CanvasImage();

            canvasImage.InitializeBitmap();
            canvasImage.canvas = databaseContext.Canvases.Find(name);
            canvasImage.Name   = name;
            databaseContext.CanvasImages.Add(canvasImage);

            databaseContext.SaveChanges();

            return(newCanvas);
        }