示例#1
0
        public IHttpActionResult Put(NoteTwoEdit note)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateNoteTwoService();

            if (!service.UpdateNote(note))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
示例#2
0
        public bool UpdateNote(NoteTwoEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Notes
                    .Single(e => e.NoteId == model.NoteId && e.OwnerId == _userId);

                entity.Title       = model.Title;
                entity.Content     = model.Content;
                entity.ModifiedUtc = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }