예제 #1
0
        public bool UpdateWriter(WriterEdit model)
        {
            var entity =
                _context.Writers
                .Single(e => e.Id == model.Id && e.AuthorId == _authorId);

            entity.Name = model.Name;
            entity.Id   = model.Id;



            return(_context.SaveChanges() == 1);
        }
예제 #2
0
        public IHttpActionResult Put(WriterEdit writer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateWriterService();

            if (!service.UpdateWriter(writer))
            {
                return(InternalServerError());
            }

            return(Ok());
        }