public JsonResult GetComments(int?postcardId) { if (postcardId == null) { return(null); } Postcard postcard = dataBase.Postcards.SingleOrDefault(p => p.Id == postcardId.Value); if (postcard == null) { return(null); } string currentUserId = User.Identity.GetUserId(); var comments = postcard.Comments.Select(c => new { id = c.Id, created = c.CreationTime, content = c.Value, fullname = c.Owner.UserName, upvote_count = c.Likers.Count, profile_picture_url = "/Content/img/user.png", user_has_upvoted = c.Likers.SingleOrDefault(l => l.Id == currentUserId) != null }); return(Json(comments, JsonRequestBehavior.AllowGet)); }
public static void AddHashTags(this Postcard postcard, string hashTags) { foreach (var tag in hashTags.Split(',').Distinct()) { postcard.AddHashTag(tag.Trim()); } }
private IEnumerator EnterWithPostcardRoutine(string message, string soundId) { yield return(1f); if (string.IsNullOrEmpty(soundId)) { soundId = "csides"; } string prefix = "event:/ui/main/postcard_"; if (int.TryParse(soundId, out int areaId)) { prefix += "ch"; } prefix += soundId; Add(postcard = new Postcard(message, prefix + "_in", prefix + "_out")); yield return(postcard.DisplayRoutine()); IEnumerator inner = orig_Routine(); while (inner.MoveNext()) { yield return(inner.Current); } }
private IEnumerator ErrorRoutine(string message) { yield return(1f); Add(postcard = new Postcard(message, "event:/ui/main/postcard_csides_in", "event:/ui/main/postcard_csides_out")); yield return(postcard.DisplayRoutine()); SaveData.Instance.CurrentSession = session; SaveData.Instance.LastArea = session.Area; Engine.Scene = new OverworldLoader(Overworld.StartMode.AreaQuit); }
private IEnumerator ErrorRoutine(string message) { yield return(1f); Add(postcard = new Postcard(message)); yield return(postcard.DisplayRoutine()); SaveData.Instance.CurrentSession = new Session(AreaKey.Default); SaveData.Instance.LastArea = AreaKey.None; Engine.Scene = new OverworldLoader(Overworld.StartMode.AreaComplete); }
public void Add_NullCountry_ReturnsNullAndDoesNotInsert() { var postcard = new Postcard { PostcardId = "POSTCARD_ID", Country = null }; var result = _postcardRepository.Add(postcard); Check.That(result).IsNull(); Check.That(_postcardRepository.All()).CountIs(0); }
private IEnumerator LevelGoneRoutine() { yield return(1f); string message = Dialog.Get("postcard_levelgone"); message = message.Replace("((player))", SaveData.Instance.Name); message = message.Replace("((sid))", session.Area.GetSID()); Add(postcard = new Postcard(message)); yield return(postcard.DisplayRoutine()); SaveData.Instance.CurrentSession = new Session(AreaKey.Default); SaveData.Instance.LastArea = AreaKey.None; Engine.Scene = new OverworldLoader(Overworld.StartMode.AreaComplete); }
private IEnumerator ErrorRoutine(string message) { yield return(1f); Add(postcard = new Postcard(message, "event:/ui/main/postcard_csides_in", "event:/ui/main/postcard_csides_out")); yield return(postcard.DisplayRoutine()); SaveData.Instance.CurrentSession = session; SaveData.Instance.LastArea = session.Area; if (AreaData.Get(session.Area) == null) { // the area we are returning to doesn't exist anymore. return to Prologue instead. SaveData.Instance.LastArea = AreaKey.Default; } Engine.Scene = new OverworldLoader(Overworld.StartMode.AreaQuit); }
private IEnumerator addForceEnabledVariantsPostcard(On.Celeste.LevelEnter.orig_Routine orig, LevelEnter self) { if (showForcedVariantsPostcard) { showForcedVariantsPostcard = false; // let's show a postcard to let the player know Extended Variants have been enabled. self.Add(forceEnabledVariantsPostcard = new Postcard(Dialog.Get("POSTCARD_EXTENDEDVARIANTS_FORCEENABLED"), "event:/ui/main/postcard_csides_in", "event:/ui/main/postcard_csides_out")); yield return(forceEnabledVariantsPostcard.DisplayRoutine()); forceEnabledVariantsPostcard = null; } // just go on with vanilla behavior (other postcards, B-side intro, etc) yield return(new SwapImmediately(orig(self))); }
public JsonResult DeletePostcard(int?id) { if (id == null) { return(Json(new { success = false })); } ApplicationDbContext db = new ApplicationDbContext(); Postcard neededPostcard = db.Postcards.SingleOrDefault(p => p.Id == id); if (neededPostcard == null) { return(Json(new { success = false })); } PostcardSearcher.ClearIndexRecord(id.Value); db.Postcards.Remove(neededPostcard); db.SaveChanges(); return(Json(new { success = true })); }
void InitStory() { int storyCount = postcardsInfo.Length; for (int i = 0; i < storyCount; i++) { GameObject postcard = CreateEmptyGameObject("Postcard", story); Postcard pComp = postcard.AddComponent <Postcard>(); pComp._year = (string)postcardsInfo[i]["_year"]; pComp._frontImage = (Sprite)postcardsInfo[i]["_frontImage"]; foreach (Hashtable hotspotInfo in (Hashtable[])postcardsInfo[i]["_hotspots"]) { GameObject hotspot = CreateEmptyGameObject("Hotspot", postcard); ApplyScript(hotspot, typeof(HotspotStory), hotspotInfo); } } }
public void Add_InvalidCountryId_ReturnsNullAndDoesNotInsert() { var postcard = new Postcard { PostcardId = "POSTCARD_ID", Country = new Country { Id = 0, Code = "XX", Name = "country name" } }; var result = _postcardRepository.Add(postcard); Check.That(result).IsNull(); Check.That(_postcardRepository.All()).CountIs(0); }
public Postcard Add(Postcard postcard) { if (postcard == null || string.IsNullOrWhiteSpace(postcard.PostcardId) || postcard.Country == null || postcard.Country.Id == 0) { return(null); } postcard.TrimAllStrings(); using var repository = _repositoryService.GetRepository(); repository.Insert(postcard, PostcrossingTrackerConstants.PostcardCollectionName); return(postcard); }
public JsonResult EditPostcard(int?id, string name, string imageUrl) { if (id == null || name == null || imageUrl == null) { return(Json(new { success = false })); } ApplicationDbContext db = new ApplicationDbContext(); Postcard neededPostcard = db.Postcards.SingleOrDefault(p => p.Id == id); if (neededPostcard == null) { return(Json(new { success = false })); } neededPostcard.Name = name; neededPostcard.ImageUrl = imageUrl; db.SaveChanges(); return(Json(new { success = true })); }
private IEnumerator EnterWithPostcardRoutine(string message, string soundId) { yield return(1f); if (string.IsNullOrEmpty(soundId)) { soundId = "csides"; } string prefix; if (soundId.StartsWith("event:/")) { // sound ID is a FMOD event, take it as is. prefix = soundId; } else if (soundId == "variants") { // sound ID is "variants", this is a special case since it is in the new_content bank. prefix = "event:/new_content/ui/postcard_variants"; } else { // if a number, use event:/ui/main/postcard_ch{number} // if not, use event:/ui/main/postcard_{text} prefix = "event:/ui/main/postcard_"; if (int.TryParse(soundId, out _)) { prefix += "ch"; } prefix += soundId; } Add(postcard = new Postcard(message, prefix + "_in", prefix + "_out")); yield return(postcard.DisplayRoutine()); IEnumerator inner = orig_Routine(); while (inner.MoveNext()) { yield return(inner.Current); } }
public JsonResult RatePostcard(int?postcardId, int?rating) { if (postcardId == null || rating == null) { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } Postcard postcard = dataBase.Postcards.SingleOrDefault(p => p.Id == postcardId.Value); if (postcard == null) { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } postcard.Rate(User.Identity.GetUserId(), rating.Value); ProcessMedalsForRatings(postcard); dataBase.SaveChanges(); return(Json(new { averageRating = postcard.AverageRating }, JsonRequestBehavior.AllowGet)); }
public static void AddHashTag(this Postcard postcard, string hashTag) { using (ApplicationDbContext db = new ApplicationDbContext()) { postcard = db.Postcards.Single(p => p.Id == postcard.Id); HashTag existingHashTag = db.HashTags.SingleOrDefault(h => h.Value == hashTag); if (existingHashTag == null) { existingHashTag = new HashTag { Value = hashTag }; HashTagSearcher.AddUpdateLuceneIndex(existingHashTag); } postcard.HashTags.Add(existingHashTag); db.SaveChanges(); } }
public static void Rate(this Postcard postcard, string userId, int value) { Rating rating = postcard.Ratings.SingleOrDefault(r => r.RaterId == userId); if (rating == null) { rating = new Rating { RelatedPostcardId = postcard.Id, RaterId = userId, Value = value }; postcard.Ratings.Add(rating); } else { rating.Value = value; } }
private static void AddToLuceneIndex(Postcard postcard, IndexWriter writer) { var searchQuery = new TermQuery(new Term("Id", postcard.Id.ToString())); writer.DeleteDocuments(searchQuery); var doc = new Document(); doc.Add(new Field("Id", postcard.Id.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field("OwnerId", postcard.OwnerId.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field("Name", postcard.Name, Field.Store.YES, Field.Index.ANALYZED)); doc.Add(new Field("ImagePath", postcard.ImagePath, Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field("ImageUrl", postcard.ImageUrl, Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field("JsonPath", postcard.JsonPath, Field.Store.YES, Field.Index.NOT_ANALYZED)); writer.AddDocument(doc); }
public ActionResult EditPostcard(int?id) { if (id == null) { ViewBag.Reason = Resources.Translations.YouDidNotEnterPostcardId; return(View("Error")); } ApplicationDbContext db = new ApplicationDbContext(); Postcard neededPostcard = db.Postcards.SingleOrDefault(p => p.Id == id); if (neededPostcard == null) { ViewBag.Reason = Resources.Translations.ThereIsNoSuchHashTags; return(View("Error")); } else if (neededPostcard.OwnerId != User.Identity.GetUserId()) { ViewBag.Reason = Resources.Translations.ThisIsNotYourPostcard; return(View("Error")); } return(View(neededPostcard)); }
public JsonResult SavePostcard(int?templateId, int?categoryId, string name, string hashTags, string imagePath, string imageUrl, string jsonPath) { if (templateId == null || categoryId == null || name == null || imageUrl == null || jsonPath == null) { return(Json(new { success = false })); } Postcard newPostcard = new Postcard { TemplateId = templateId, CategoryId = categoryId, Name = name, ImagePath = imagePath, ImageUrl = imageUrl, JsonPath = jsonPath, OwnerId = User.Identity.GetUserId() }; ApplicationDbContext db = new ApplicationDbContext(); db.Postcards.Add(newPostcard); db.SaveChanges(); PostcardSearcher.AddUpdateLuceneIndex(newPostcard); newPostcard.AddHashTags(hashTags); return(Json(new { success = true })); }
public void Get_PostcardExists_ReturnsPostcard() { var country = new Country { Code = "CC", Name = "country name" }; InsertData(country); var postcardUnderTest = new Postcard { Country = country, PostcardId = "POSTCARD_ID" }; InsertData(postcardUnderTest); var result = _postcardRepository.Get(postcard => postcard.PostcardId == postcardUnderTest.PostcardId); Check.That(result).IsNotNull(); Check.That(result).HasFieldsWithSameValues(postcardUnderTest); }
private void ProcessMedalsForRatings(Postcard postcard) { ApplicationUser user = dataBase.Users.Single(u => u.Id == postcard.OwnerId); var highRatings = postcard.Ratings.Count > 0 ? postcard.Ratings. Where(r => r.Value == 5 && r.RaterId != user.Id).ToList().Count : 0; Medal medal = null; if (highRatings >= 15) { medal = dataBase.Medals.Single(m => m.Description == "ForFifteenHighRatings"); if (user.Medals.SingleOrDefault(m => m.Id == medal.Id) == null) { user.Medals.Add(medal); } } else if (highRatings >= 10) { medal = dataBase.Medals.Single(m => m.Description == "ForTenHighRatings"); if (user.Medals.SingleOrDefault(m => m.Id == medal.Id) == null) { user.Medals.Add(medal); } } else if (highRatings >= 5) { medal = dataBase.Medals.Single(m => m.Description == "ForFiveHighRatings"); if (user.Medals.SingleOrDefault(m => m.Id == medal.Id) == null) { user.Medals.Add(medal); } } dataBase.SaveChanges(); }
public void Add_ValidPostcard_InsertsAndReturnsPostcard() { var country = new Country { Code = "XX", Name = "country name" }; InsertData(country); var postcard = new Postcard { PostcardId = "POSTCARD_ID", Country = country }; var result = _postcardRepository.Add(postcard); var allPostcards = _postcardRepository.All().ToList(); Check.That(result).IsNotNull(); Check.That(allPostcards).CountIs(1); Check.That(allPostcards[0]).HasFieldsWithSameValues(postcard); }
public GoogleGearsAdvanced() { //Native.Window.alert("alert 1"); CreateStyles(); //Native.Window.alert("alert 2"); var shadow = new div { className = "shadow" }; var toolbar = new div { className = "toolbar" }; var workspace0 = new div { className = "workspace0" }; var workspace = new div { className = "workspace" }; workspace0.appendChild( new div("You can create new postcards by clicking on the background image. You can drag those postcards by their borders. You can use your mouse wheel to zoom in or out, too. All postcards will be saved via webSQL. Doubleclick a postcard to delete it.")); shadow.appendChild(workspace0, workspace, toolbar); //toolbar.innerHTML = "<a href='http://gears.google.com/'>get google gears</a> | <a href='http://jsc.sourceforge.net/'>jsc homepage</a> | <a href='http://zproxy.wordpress.com/'>blog</a>"; //AppendError(workspace0, "loading 1..."); var BackgroundTween = new TweenDataDouble(); BackgroundTween.ValueChanged += delegate { workspace.style.Opacity = BackgroundTween.Value; }; BackgroundTween.Value = 0.5; workspace.onmouseover += delegate { BackgroundTween.Value = 0; }; workspace.onmouseout += delegate { BackgroundTween.Value = 0.5; }; //AppendError(workspace0, "loading 2..."); //var cc = new SQLiteConnection(); //cc.Open(); new { }.With( async delegate { while (true) { await Native.window.async.onframe; // we are logging a lot. idle more for now await Task.Delay(500); var Count = await new xxPostcard().Create().CountAsync(); // let UI know how many we have Native.document.title = new { Count }.ToString(); // chrome style may not show title toolbar.innerText = new { Count }.ToString(); // can we do conditional css here? //toolbar.style.color = "blue"; //await toolbar.async.onclick; //// undo //toolbar.style.color = ""; } } ); new HTML.Images.FromAssets.postcard_alpha().InvokeOnComplete( postcard => new HTML.Images.FromAssets.postcard_alpha_200_unfocus().InvokeOnComplete( postcard200 => { // at this point we have the image and we know how large it is //AppendError(workspace0, "loading 3..."); // X:\jsc.svn\examples\javascript\forms\SQLiteConsoleExperiment\SQLiteConsoleExperiment\ApplicationControl.cs // X:\jsc.svn\examples\javascript\Test\TestSQLiteConnection\TestSQLiteConnection\Application.cs // Cannot read property 'transaction' of null" new xxPostcard().Create(); //catch (System.Exception exc) //{ // var err_msg = exc.Message; // AppendError(workspace0, err_msg); //} //AppendError(workspace0, "loading 4..."); #region Spawn Func <PostcardEntry, Postcard> Spawn = template => { var p2 = new Postcard(postcard, postcard200, workspace); p2.CurrentDrag.Position.X = template.X; p2.CurrentDrag.Position.Y = template.Y; p2.AttachTo(shadow); System.Console.WriteLine("new: " + p2.Id); if (template.Text == null) { template.Text = new[] { "Hello!", "Yo!", "Whuzza!", "Howdy!", "Cheers!" }.Randomize().First() + "\nWrite something here!"; } if (template.Zoom100 == 0) { template.Zoom100 = (int)System.Math.Floor((new System.Random().NextDouble() + 0.5) * 100); } p2.Content.value = template.Text; System.Console.WriteLine("SetZoom: " + new { template.Zoom100 }); p2.SetZoom(template.Zoom100 / 100.0); if (template.Id == null) { try { new xxPostcard().InsertAsync( new xxPostcardRow { Id = p2.Id, Text = p2.Text, Zoom100 = (int)System.Math.Floor(p2.Zoom * 100), X = p2.CurrentDrag.Position.X, Y = p2.CurrentDrag.Position.Y } ); } catch (System.Exception exc) { AppendError(workspace0, exc.Message); } } else { p2.Id = template.Id; } #region RightClick p2.RightClick += delegate { System.Console.WriteLine("dispose: " + p2.Id); p2.Dispose(); //db.execute("delete from Postcards where Id = ?", p2.Id); Console.WriteLine("delete:"); // 21:15078ms delete: view - source:41361 //Uncaught RangeError: Maximum call stack size exceeded ( from x in new xxPostcard() where x.Id == p2.Id select x ).Delete(); //new xPostcard().Where(x => x.Id == p2.Id).Delete(cc); Console.WriteLine("delete: done?"); }; #endregion #region DoubleClick p2.DoubleClick += delegate { System.Console.WriteLine("dispose: " + p2.Id); p2.Dispose(); //db.execute("delete from Postcards where Id = ?", p2.Id); Console.WriteLine("delete:"); ( from x in new xxPostcard() where x.Id == p2.Id select x ).Delete(); //new xPostcard().Where(x => x.Id == p2.Id).Delete(cc); Console.WriteLine("delete: done?"); }; #endregion #region Changed p2.Changed += delegate { System.Console.WriteLine("changed: " + new PostcardEntry { Id = p2.Id, Text = p2.Text, Zoom100 = (int)System.Math.Floor(p2.Zoom * 100), X = p2.CurrentDrag.Position.X, Y = p2.CurrentDrag.Position.Y }.ToString()); Console.WriteLine("delete:"); new xxPostcard().Delete(x => x.Id == p2.Id); new xxPostcard().InsertAsync( new xxPostcardRow { Id = p2.Id, Text = p2.Text, Zoom100 = (int)System.Math.Floor(p2.Zoom * 100), X = p2.CurrentDrag.Position.X, Y = p2.CurrentDrag.Position.Y } ); }; #endregion System.Console.WriteLine("item: " + template.ToString()); p2.ZoomAndMove(); p2.CurrentDrag.DragStart += delegate { p2.AttachTo(shadow); }; return(p2); }; #endregion workspace.onclick += delegate(IEvent ev) { Spawn( new PostcardEntry { X = ev.CursorX, Y = ev.CursorY } ); }; #region LoadFromDatabase new { }.With( async delegate { var query = from Data in new xxPostcard() select Data; foreach (var v in await query.AsEnumerableAsync()) { // 13:232ms {{ Text = hey, X = 355.0, Y = 243.0, Zoom100 = 30.0 }} //Console.WriteLine(new { v.Text, v.X, v.Y, v.Zoom100 }); Spawn( new PostcardEntry { Id = v.Id, Text = v.Text, X = (int)v.X, Y = (int)v.Y, Zoom100 = Math.Max(60, (int)v.Zoom100), } ); } } ); #endregion } ) ); Native.Document.body.appendChild(shadow); }
public GoogleGearsAdvanced() { //Native.Window.alert("alert 1"); CreateStyles(); //Native.Window.alert("alert 2"); var shadow = new div { className = "shadow" }; var toolbar = new div { className = "toolbar" }; var workspace0 = new div { className = "workspace0" }; var workspace = new div { className = "workspace" }; workspace0.appendChild( new div("You can create new postcards by clicking on the background image. You can drag those postcards by their borders. You can use your mouse wheel to zoom in or out, too. All postcards will be saved via webSQL. Doubleclick a postcard to delete it.")); shadow.appendChild(workspace0, workspace, toolbar); //toolbar.innerHTML = "<a href='http://gears.google.com/'>get google gears</a> | <a href='http://jsc.sourceforge.net/'>jsc homepage</a> | <a href='http://zproxy.wordpress.com/'>blog</a>"; //AppendError(workspace0, "loading 1..."); var BackgroundTween = new TweenDataDouble(); BackgroundTween.ValueChanged += delegate { workspace.style.Opacity = BackgroundTween.Value; }; BackgroundTween.Value = 0.5; workspace.onmouseover += delegate { BackgroundTween.Value = 0; }; workspace.onmouseout += delegate { BackgroundTween.Value = 0.5; }; //AppendError(workspace0, "loading 2..."); //var cc = new SQLiteConnection(); //cc.Open(); new { }.With( async delegate { while (true) { await Native.window.async.onframe; // we are logging a lot. idle more for now await Task.Delay(500); var Count = await new xxPostcard().Create().CountAsync(); // let UI know how many we have Native.document.title = new { Count }.ToString(); // chrome style may not show title toolbar.innerText = new { Count }.ToString(); // can we do conditional css here? //toolbar.style.color = "blue"; //await toolbar.async.onclick; //// undo //toolbar.style.color = ""; } } ); new HTML.Images.FromAssets.postcard_alpha().InvokeOnComplete( postcard => new HTML.Images.FromAssets.postcard_alpha_200_unfocus().InvokeOnComplete( postcard200 => { // at this point we have the image and we know how large it is //AppendError(workspace0, "loading 3..."); // X:\jsc.svn\examples\javascript\forms\SQLiteConsoleExperiment\SQLiteConsoleExperiment\ApplicationControl.cs // X:\jsc.svn\examples\javascript\Test\TestSQLiteConnection\TestSQLiteConnection\Application.cs // Cannot read property 'transaction' of null" new xxPostcard().Create(); //catch (System.Exception exc) //{ // var err_msg = exc.Message; // AppendError(workspace0, err_msg); //} //AppendError(workspace0, "loading 4..."); #region Spawn Func<PostcardEntry, Postcard> Spawn = template => { var p2 = new Postcard(postcard, postcard200, workspace); p2.CurrentDrag.Position.X = template.X; p2.CurrentDrag.Position.Y = template.Y; p2.AttachTo(shadow); System.Console.WriteLine("new: " + p2.Id); if (template.Text == null) { template.Text = new[] { "Hello!", "Yo!", "Whuzza!", "Howdy!", "Cheers!" }.Randomize().First() + "\nWrite something here!"; } if (template.Zoom100 == 0) { template.Zoom100 = (int)System.Math.Floor((new System.Random().NextDouble() + 0.5) * 100); } p2.Content.value = template.Text; System.Console.WriteLine("SetZoom: " + new { template.Zoom100 }); p2.SetZoom(template.Zoom100 / 100.0); if (template.Id == null) { try { new xxPostcard().InsertAsync( new xxPostcardRow { Id = p2.Id, Text = p2.Text, Zoom100 = (int)System.Math.Floor(p2.Zoom * 100), X = p2.CurrentDrag.Position.X, Y = p2.CurrentDrag.Position.Y } ); } catch (System.Exception exc) { AppendError(workspace0, exc.Message); } } else { p2.Id = template.Id; } #region RightClick p2.RightClick += delegate { System.Console.WriteLine("dispose: " + p2.Id); p2.Dispose(); //db.execute("delete from Postcards where Id = ?", p2.Id); Console.WriteLine("delete:"); // 21:15078ms delete: view - source:41361 //Uncaught RangeError: Maximum call stack size exceeded ( from x in new xxPostcard() where x.Id == p2.Id select x ).Delete(); //new xPostcard().Where(x => x.Id == p2.Id).Delete(cc); Console.WriteLine("delete: done?"); }; #endregion #region DoubleClick p2.DoubleClick += delegate { System.Console.WriteLine("dispose: " + p2.Id); p2.Dispose(); //db.execute("delete from Postcards where Id = ?", p2.Id); Console.WriteLine("delete:"); ( from x in new xxPostcard() where x.Id == p2.Id select x ).Delete(); //new xPostcard().Where(x => x.Id == p2.Id).Delete(cc); Console.WriteLine("delete: done?"); }; #endregion #region Changed p2.Changed += delegate { System.Console.WriteLine("changed: " + new PostcardEntry { Id = p2.Id, Text = p2.Text, Zoom100 = (int)System.Math.Floor(p2.Zoom * 100), X = p2.CurrentDrag.Position.X, Y = p2.CurrentDrag.Position.Y }.ToString()); Console.WriteLine("delete:"); new xxPostcard().Delete(x => x.Id == p2.Id); new xxPostcard().InsertAsync( new xxPostcardRow { Id = p2.Id, Text = p2.Text, Zoom100 = (int)System.Math.Floor(p2.Zoom * 100), X = p2.CurrentDrag.Position.X, Y = p2.CurrentDrag.Position.Y } ); }; #endregion System.Console.WriteLine("item: " + template.ToString()); p2.ZoomAndMove(); p2.CurrentDrag.DragStart += delegate { p2.AttachTo(shadow); }; return p2; }; #endregion workspace.onclick += delegate (IEvent ev) { Spawn( new PostcardEntry { X = ev.CursorX, Y = ev.CursorY } ); }; #region LoadFromDatabase new { }.With( async delegate { var query = from Data in new xxPostcard() select Data; foreach (var v in await query.AsEnumerableAsync()) { // 13:232ms {{ Text = hey, X = 355.0, Y = 243.0, Zoom100 = 30.0 }} //Console.WriteLine(new { v.Text, v.X, v.Y, v.Zoom100 }); Spawn( new PostcardEntry { Id = v.Id, Text = v.Text, X = (int)v.X, Y = (int)v.Y, Zoom100 = Math.Max(60, (int)v.Zoom100), } ); } } ); #endregion } ) ); Native.Document.body.appendChild(shadow); }
public static void AddUpdateLuceneIndex(Postcard postcard) { AddUpdateLuceneIndex(new List<Postcard> { postcard }); }
public static void AddUpdateLuceneIndex(Postcard postcard) { AddUpdateLuceneIndex(new List <Postcard> { postcard }); }
public JsonResult SavePostcard(int? templateId, int? categoryId, string name, string hashTags, string imagePath, string imageUrl, string jsonPath) { if (templateId == null || categoryId == null || name == null || imageUrl == null || jsonPath == null) { return Json(new { success = false }); } Postcard newPostcard = new Postcard { TemplateId = templateId, CategoryId = categoryId, Name = name, ImagePath = imagePath, ImageUrl = imageUrl, JsonPath = jsonPath, OwnerId = User.Identity.GetUserId() }; ApplicationDbContext db = new ApplicationDbContext(); db.Postcards.Add(newPostcard); db.SaveChanges(); PostcardSearcher.AddUpdateLuceneIndex(newPostcard); newPostcard.AddHashTags(hashTags); return Json(new { success = true }); }
public Postcard GetOrAdd(Postcard postcard) { return(Get(postcardModel => postcardModel.PostcardId == postcard.PostcardId) ?? Add(postcard)); }