예제 #1
0
        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));
        }
예제 #2
0
        public Sonnet GetSonnet(int id)
        {
            var    userId = User.Identity.GetUserId();
            Sonnet sonnet = repo.GetSingleSonnet(userId, id);

            if (sonnet == null)
            {
                NotFound();
            }

            return(sonnet);
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
파일: Sonnet_Dialog.cs 프로젝트: KDE/kimono
 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);
 }
예제 #6
0
 public Speller(Sonnet.Speller speller)
     : this((Type) null)
 {
     CreateProxy();
     interceptor.Invoke("Speller#", "Speller(const Sonnet::Speller&)", typeof(void), typeof(Sonnet.Speller), speller);
 }
예제 #7
0
 public bool TestAttribute(Sonnet.Speller.Attribute attr)
 {
     return (bool) interceptor.Invoke("testAttribute$", "testAttribute(Sonnet::Speller::Attribute) const", typeof(bool), typeof(Sonnet.Speller.Attribute), attr);
 }
예제 #8
0
 public void SetAttribute(Sonnet.Speller.Attribute attr)
 {
     interceptor.Invoke("setAttribute$", "setAttribute(Sonnet::Speller::Attribute)", typeof(void), typeof(Sonnet.Speller.Attribute), attr);
 }
예제 #9
0
 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);
 }
예제 #10
0
파일: KTextEdit.cs 프로젝트: KDE/kimono
 /// <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);
 }