コード例 #1
0
        public void SaveComicStory(ComicStory comicStory)
        {
            #region Testing
            //if (comicStory == null) //just for testing
            //{
            //    comicStory = new ComicStory()
            //    {
            //        Name = "Menny Story 1",
            //    };

            //    var tile = new ComicTile()
            //    {
            //        Name = "first tile",
            //        Image = "encoded image",
            //    };
            //    comicStory.Tiles.Add(tile);

            //    tile.Overlays.Add(new TileOverlay()
            //    {
            //        Height = 20,
            //        Text = "hello",
            //        Width = 2,
            //        X = 1,
            //        Y = 1,
            //        Type = TileOverlayTypes.Baloon1,
            //    });
            //}
            #endregion

            //Insert or update according to ComicStory.Id property
            _comicStoryCollection.Save(comicStory);
        }
コード例 #2
0
        public ActionResult Save(ComicStory comicStory)
        {
            //_mongoRepositiry.SaveComicStory(comicStory);

            //SignalR
            //var context = GlobalHost.ConnectionManager.GetHubContext<StoryNotificationsHub>();
            //context.Clients.Group(comicStory.Id).notifyHasUpdates();

            //return the Id in case the story is new
            return(Json(new { status = "OK", comicStoryId = comicStory.Id }));
        }
コード例 #3
0
        public JsonNetResult Create(ComicStory comicStory)
        {
            //reset the Id
            comicStory.Id = null;

            try
            {
                _mongoRepositiry.SaveComicStory(comicStory);
            }
            catch (FormatException)
            {
                throw new ArgumentException("The story could not be created");
            }

            //ActionResult
            JsonNetResult jsonNetResult = new JsonNetResult();

            jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented;
            jsonNetResult.Data       = comicStory;
            return(jsonNetResult);
        }