public IHttpActionResult PostSonnet(Sonnet sonnet) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var userId = User.Identity.GetUserId(); if (userId == null) { sonnet.OwnerId = null; sonnet.Public = true; } else { sonnet.OwnerId = userId; } sonnet.Created = DateTime.Now; sonnet.NewUrl = Helpers.EncryptionHelp.AndGo(); db.Sonnets.Add(sonnet); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = sonnet.Id }, sonnet)); }
public Sonnet GetSonnet(int id) { var userId = User.Identity.GetUserId(); Sonnet sonnet = repo.GetSingleSonnet(userId, id); if (sonnet == null) { NotFound(); } return(sonnet); }
public IHttpActionResult DeleteSonnet(int id) { var userId = User.Identity.GetUserId(); Sonnet sonnet = db.Sonnets .Where( s => s.Id == id && s.OwnerId == userId ) .FirstOrDefault(); if (sonnet == null) { return(NotFound()); } db.Sonnets.Remove(sonnet); db.SaveChanges(); return(Ok(sonnet)); }
public IHttpActionResult PutSonnet(int id, Sonnet sonnet) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var userId = User.Identity.GetUserId(); sonnet.Id = id; //How to get OwnerId in from Form if (sonnet.OwnerId != userId) { return(BadRequest()); } db.Entry(sonnet).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SonnetExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public Dialog(Sonnet.BackgroundChecker checker, QWidget parent) : this((Type) null) { CreateProxy(); interceptor.Invoke("Dialog##", "Dialog(Sonnet::BackgroundChecker*, QWidget*)", typeof(void), typeof(Sonnet.BackgroundChecker), checker, typeof(QWidget), parent); }
public Speller(Sonnet.Speller speller) : this((Type) null) { CreateProxy(); interceptor.Invoke("Speller#", "Speller(const Sonnet::Speller&)", typeof(void), typeof(Sonnet.Speller), speller); }
public bool TestAttribute(Sonnet.Speller.Attribute attr) { return (bool) interceptor.Invoke("testAttribute$", "testAttribute(Sonnet::Speller::Attribute) const", typeof(bool), typeof(Sonnet.Speller.Attribute), attr); }
public void SetAttribute(Sonnet.Speller.Attribute attr) { interceptor.Invoke("setAttribute$", "setAttribute(Sonnet::Speller::Attribute)", typeof(void), typeof(Sonnet.Speller.Attribute), attr); }
public void SetAttribute(Sonnet.Speller.Attribute attr, bool b) { interceptor.Invoke("setAttribute$$", "setAttribute(Sonnet::Speller::Attribute, bool)", typeof(void), typeof(Sonnet.Speller.Attribute), attr, typeof(bool), b); }
/// <remarks> /// Sets a custom backgound spell highlighter for this text edit. /// Normally, the highlighter returned by createHighlighter() will be /// used to detect and highlight incorrectly spelled words, but this /// function allows to set a custom highlighter. /// This has to be called after enabling spell checking with /// setCheckSpellingEnabled(), otherwise it has no effect. /// <param> name="highLighter" the new highlighter which will be used now /// </param></remarks> <short> Sets a custom backgound spell highlighter for this text edit.</short> /// <see> highlighter</see> /// <see> createHighlighter</see> public void SetHighlighter(Sonnet.Highlighter _highLighter) { interceptor.Invoke("setHighlighter#", "setHighlighter(Sonnet::Highlighter*)", typeof(void), typeof(Sonnet.Highlighter), _highLighter); }