public EditorialDTO Insert(EditorialDTO editorialViewModel)
        {
            if (string.IsNullOrEmpty(editorialViewModel.Nombre) || string.IsNullOrWhiteSpace(editorialViewModel.Nombre) ||
                string.IsNullOrEmpty(editorialViewModel.Direccion) || string.IsNullOrWhiteSpace(editorialViewModel.Direccion) ||
                string.IsNullOrEmpty(editorialViewModel.Email) || string.IsNullOrWhiteSpace(editorialViewModel.Email))
            {
                throw new ApplicationException("Datos incompletos");
            }


            if (_context.Tb_editoriales.Any(e => e.Editorial_nombre.ToUpper() == editorialViewModel.Nombre.ToUpper()))
            {
                string mensaje = string.Format("Ya existe la editorial {0}", editorialViewModel.Nombre);
                throw new ApplicationException(mensaje);
            }

            Tb_Editorial editorial = Map(editorialViewModel);

            _context.Add(editorial);
            if (_context.SaveChanges() >= 1)
            {
                return(Map(editorial));
            }
            else
            {
                return(null);
            }
        }
 private EditorialDTO Map(Tb_Editorial editorial)
 {
     return(editorial == null ? null : new EditorialDTO()
     {
         Id = editorial.Editorial_id,
         Nombre = editorial.Editorial_nombre,
         Direccion = editorial.Editorial_Direccion,
         Telefono = editorial.Editorial_Telefono,
         Email = editorial.Editorial_email,
         LibrosRegistrados = editorial.Editorial_librosRegistrados
     });
 }