Ejemplo n.º 1
0
        public bool CreateWriter(WriterCreate writer)
        {
            var entity = new Writer

            {
                Name     = writer.Name,
                AuthorId = _authorId
            };



            _context.Writers.Add(entity);
            return(_context.SaveChanges() == 1);
        }
Ejemplo n.º 2
0
        public IHttpActionResult Post(WriterCreate writer)
        {
            if (writer is null)
            {
                return(BadRequest());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var Service      = CreateWriterService();
            var isSuccessful = Service.CreateWriter(writer);

            if (!isSuccessful)
            {
                return(InternalServerError());
            }
            return(Ok("New Writer Created"));
        }