public void check_the_same_ISBN()
        {
            var isbn1 = new ISBN("978-957-331-724-1");
            var isbn2 = new ISBN("978-957-331-724-1");

            isbn1.Should().Be(isbn2);
        }
Exemplo n.º 2
0
        AlterarLivroResponse IServiceLivro.AlterarLivro(AlterarLivroRequest request)
        {
            if (request == null)
            {
                AddNotification("AlterarLivroRequest", Message.E_OBRIGATORIO_PREENCHIMENTO_DE_X0.ToFormat("AlterarJogadorRequest"));
            }

            Livro livro = _repositoryLivro.GetById(request.Id);

            if (livro == null)
            {
                AddNotification("Id", Message.DADOS_NAO_ENCONTRADOS);
                return(null);
            }
            if (livro.Isbn.NumeroIsbn == request.Isbn)
            {
                AddNotification("ISBN", Message.JA_EXISTE_UM_LIVRO_COM_ISBN_X0.ToFormat("ISBN", request.Isbn));
            }
            if (this.IsInvalid())
            {
                return(null);
            }

            var nomeAutor = new Nome(request.PrimeiroNomeAutor, request.SobrenomeAutor);
            var isbn      = new ISBN(request.Isbn);

            Livro novoLivro = new Livro(isbn, nomeAutor, request.NomeLivro, request.Preço, request.DataPublicacao, request.ImagemDaCapa);

            AddNotifications(nomeAutor, isbn);

            _repositoryLivro.ToEdit(novoLivro);

            return((AlterarLivroResponse)livro);
        }
        private void Search()
        {
            using (StartOperation())
            {
                if (ISBN.IsNullOrEmpty() && SearchString.IsNullOrEmpty())
                {
                    Amounts = new BookAmount[] { };
                    return;
                }

                var query = RepositoryProvider.GetRepository <BookAmount>()
                            .GetAll(ba => ba.Book.Writers)
                            .Where(ba => ba.BranchId == Employee.BranchId);

                if (!ISBN.IsNullOrEmpty())
                {
                    query = query.Where(ba => ba.Book.ISBN.Contains(ISBN));
                }
                else if (!SearchString.IsNullOrEmpty())
                {
                    query = query.Where(ba => ba.Book.Title.Contains(SearchString) ||
                                        ba.Book.Writers.Any(w => w.LastName.Contains(SearchString)));
                }

                Amounts = query.ToList();
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (ISBN != null)
         {
             hashCode = hashCode * 59 + ISBN.GetHashCode();
         }
         if (Nome != null)
         {
             hashCode = hashCode * 59 + Nome.GetHashCode();
         }
         if (Preco != null)
         {
             hashCode = hashCode * 59 + Preco.GetHashCode();
         }
         if (Autor != null)
         {
             hashCode = hashCode * 59 + Autor.GetHashCode();
         }
         if (Editora != null)
         {
             hashCode = hashCode * 59 + Editora.GetHashCode();
         }
         if (Categora != null)
         {
             hashCode = hashCode * 59 + Categora.GetHashCode();
         }
         return(hashCode);
     }
 }
Exemplo n.º 5
0
        public void ISBN_IsValid_True()
        {
            var isbn      = new ISBN();
            var validISBN = "0201314525";

            Assert.IsTrue(isbn.IsValid(validISBN));
        }
Exemplo n.º 6
0
        public void ShouldCreateABook()
        {
            var authorList        = GetAuthorList();
            var expectedISBN      = new ISBN(ISBN);
            var expectedPublisher = new Publisher(PUBLISHER_NAME);

            var book = new Book(
                TITLE,
                expectedISBN,
                GetAuthorList(),
                PAGE_COUNT,
                expectedPublisher,
                YEAR_PUBLICATION,
                edition: 3,
                CITY);

            book.Should().NotBeNull();
            book.Title.Should().Be(TITLE);
            book.ISBN.Should().Be(expectedISBN);
            book.Authors.Should().BeEquivalentTo(authorList);
            book.PageCount.Should().Be(PAGE_COUNT);
            book.Publisher.Should().Be(expectedPublisher);
            book.YearPublication.Should().Be(YEAR_PUBLICATION);
            book.Edition.Should().Be(EDITION);
            book.City.Should().Be(CITY);
        }
Exemplo n.º 7
0
        public XElement ToXML()
        {
            var xPublishInfo = new XElement(Fb2Const.fb2DefaultNamespace + PublishInfoElementName);

            if (BookTitle != null)
            {
                xPublishInfo.Add(BookTitle.ToXML(BookNameElementName));
            }
            if (Publisher != null)
            {
                xPublishInfo.Add(Publisher.ToXML(PublisherElementName));
            }
            if (City != null)
            {
                xPublishInfo.Add(City.ToXML(CityElementName));
            }
            if (Year != null)
            {
                xPublishInfo.Add(new XElement(Fb2Const.fb2DefaultNamespace + YearElementName, Year.ToString()));
            }
            if (ISBN != null)
            {
                xPublishInfo.Add(ISBN.ToXML(ISBNElementName));
            }
            foreach (SequenceType sec in ItemSequences)
            {
                xPublishInfo.Add(sec.ToXML());
            }

            return xPublishInfo;
        }
        protected override void Execute(CodeActivityContext context)
        {
            // Open the config file and get the Request Address
            Configuration config = ConfigurationManager
                                   .OpenExeConfiguration(ConfigurationUserLevel.None);
            AppSettingsSection app =
                (AppSettingsSection)config.GetSection("appSettings");

            // Create a ReservationRequest class and populate
            // it with the input arguments
            ReservationRequest r = new ReservationRequest
                                   (
                Title.Get(context),
                Author.Get(context),
                ISBN.Get(context),
                new Branch
            {
                BranchName = app.Settings["Branch Name"].Value,
                BranchID   = new Guid(app.Settings["ID"].Value),
                Address    = app.Settings["Address"].Value
            }
                                   );

            // Store the request in the OutArgument
            Request.Set(context, r);

            // Store the address in the OutArgument
            RequestAddress.Set(context, app.Settings["Request Address"].Value);
        }
Exemplo n.º 9
0
        public void ISBN_IsValid_False()
        {
            var isbn        = new ISBN();
            var invalidISBN = "0201314535";

            Assert.IsFalse(isbn.IsValid(invalidISBN));
        }
Exemplo n.º 10
0
        public int DeleteISBN(ISBN entity)
        {
            db.isbns.Remove(entity);
            db.SaveChanges();

            return(0);
        }
Exemplo n.º 11
0
 public void CreateISBN13ShouldBeNotValid(string isbnString)
 {
     Assert.Throws <InvalidISBNException>(() =>
     {
         ISBN isbn = isbnString;
     });
 }
Exemplo n.º 12
0
        /// <summary>
        /// Checks whether and of the Properties of this object contains the string passed in the argument
        /// </summary>
        /// <param name="searchToken">string used to compare with this object's fields and properties</param>
        /// <returns>Returns true if this object contains the search token, false otherwise</returns>
        public bool ContainsToken(string searchToken)
        {
            //remove white spaces
            string token = new string(searchToken.ToCharArray().Where(c => !Char.IsWhiteSpace(c)).ToArray());

            if (Title.ToLower().Contains(token))
            {
                return(true);
            }

            string authorName = Author.Person.FirstName + Author.Person.LastName;

            if (authorName.ToLower().Contains(token.ToLower()))
            {
                return(true);
            }

            if (ISBN.Contains(token))
            {
                return(true);
            }
            if (Subject.ToLower().Contains(token))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 13
0
        public int SaveISBN(ISBN entity)
        {
            db.isbns.Add(entity);
            db.SaveChanges();

            return(0);
        }
Exemplo n.º 14
0
        public void ShouldCreateISBN()
        {
            var isbn = new ISBN(VALID_ISBN);

            isbn.Should().NotBeNull();
            isbn.Value.Should().Be(VALID_ISBN);
        }
Exemplo n.º 15
0
        public void ISBN_IsValid_GenerateException()
        {
            var isbn      = new ISBN();
            var shortISBN = "02013145";

            isbn.IsValid(shortISBN);
        }
Exemplo n.º 16
0
 public Book(ISBN isbn, Title title, double price)
     : this()
 {
     ISBN  = isbn;
     Title = title;
     Price = price;
 }
Exemplo n.º 17
0
 public void CreateISBN10ShouldBeValid(string isbnString)
 {
     Assert.DoesNotThrow(() =>
     {
         ISBN isbn = isbnString;
     });
 }
Exemplo n.º 18
0
        public BookProfile()
        {
            string asdf = new ISBN("asdf");

            CreateMap <BookModel, Book>()
            .ForMember(entity => entity.Id, opt =>
                       opt.MapFrom(model => model.Id))
            .ForMember(entity => entity.YearPublication, opt =>
                       opt.MapFrom(model => model.Year))
            .ForMember(entity => entity.Authors, opt =>
                       opt.MapFrom(model =>
                                   model.Authors.Select(bookAuthor => bookAuthor.Author).ToList()));

            CreateMap <Book, BookModel>()
            .ForMember(model => model.ISBN, opt =>
                       opt.MapFrom(entity => entity.ISBN.Value))
            .ForMember(model => model.Year, opt =>
                       opt.MapFrom(entity => entity.YearPublication))
            .ForMember(model => model.Authors, opt =>
                       opt.MapFrom(entity => entity.Authors
                                   .Select(author => new BookAuthor
            {
                BookId   = entity.Id,
                AuthorId = author.Id,
                Author   = new AuthorModel
                {
                    Id   = author.Id,
                    Name = author.Name
                }
            }).ToList()
                                   ));
        }
Exemplo n.º 19
0
        public async Task <string> GetBookByISBN(string isbn)
        {
            var isbnUtility = new ISBN();

            isbn = isbn.Replace("-", "").Replace(" ", "").Replace(".", "").Replace("X", "x");
            var version = isbnUtility.GetISBNVersion(isbn);

            if (version == VERSION.INVALID)
            {
                throw new UserFriendlyException("isbn is invalid.", "2000");
            }

            var filter = Builders <BsonDocument> .Filter.Eq("isbn13", isbn);

            if (version == VERSION.ISBN10)
            {
                filter = Builders <BsonDocument> .Filter.Eq("isbn10", isbn);
            }

            var projection = Builders <BsonDocument> .Projection.Exclude("_id");

            var document = await _mongoDatabase.GetCollection <BsonDocument>("ResDoubanBook").Find(filter).Project(projection).FirstOrDefaultAsync();

            if (document == null)
            {
                throw new UserFriendlyException("can't find document.", "2001");
            }
            return(document.ToString());
        }
Exemplo n.º 20
0
        public void ShouldBeInvalidWhenBiggerThan12Digits()
        {
            var isbn = new ISBN(INVALID_ISBN_BIGGER);

            var validISBN = isbn.IsValid();

            validISBN.Should().BeFalse();
        }
Exemplo n.º 21
0
        public void TestIsValidISBN_CheckDigit()
        {
            ISBN   iSBN    = new ISBN();
            string isnb10  = "0-470-84525-2";
            bool   isvalid = iSBN.IsValidISBN(isnb10);

            Assert.IsTrue(isvalid);
        }
Exemplo n.º 22
0
        public void TestIsValidISBN_IgnoreHypen()
        {
            ISBN   iSBN    = new ISBN();
            string isnb10  = "99921-58-10-7";
            bool   isvalid = iSBN.IsValidISBN(isnb10);

            Assert.IsTrue(isvalid);
        }
Exemplo n.º 23
0
        public void TestIsValidISBN_IgnoreSpace()
        {
            ISBN   iSBN    = new ISBN();
            string isnb10  = "0 471 60695 2";
            bool   isvalid = iSBN.IsValidISBN(isnb10);

            Assert.IsTrue(isvalid);
        }
Exemplo n.º 24
0
        public void ShouldHaveOnlyDigits()
        {
            var isbn = new ISBN(INVALID_ISBN_LETTERS);

            var validISBN = isbn.IsValid();

            validISBN.Should().BeFalse();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ViewState["ReferrerUrl"] = Request.UrlReferrer.ToString();
         ISBN.Focus();
     }
 }
Exemplo n.º 26
0
        public void ShouldBeInvalidWhenHaveLessThan12Digits()
        {
            var isbn = new ISBN(INVALID_ISBN_SMALL);

            var validISBN = isbn.IsValid();

            validISBN.Should().BeFalse();
        }
Exemplo n.º 27
0
 public IQueryable <BaseType.Kitap> ISBNQuery(IQueryable <BaseType.Kitap> queryable)
 {
     if (!string.IsNullOrEmpty(ISBN))
     {
         return(queryable.Where(s => s.ISBN.Trim() == ISBN.Trim()));
     }
     return(queryable);
 }
Exemplo n.º 28
0
        public void ConvertObjectToStringWithValueOfMethodPresentUsingToString()
        {
            ISBN.Reset();
            Assert.Equal("123456789", ConversionService.Convert <string>(new ISBN("123456789")));

            Assert.Equal(1, ISBN.ConstructorCount);
            Assert.Equal(0, ISBN.ValueOfCount);
            Assert.Equal(1, ISBN.ToStringCount);
        }
Exemplo n.º 29
0
        public ActionResult ISBNDeleteConfirmed(int id)
        {
            ISBN iSBN = db.ISBNs.Find(id);

            db.ISBNs.Remove(iSBN);
            db.SaveChanges();
            DisplaySuccessMessage("Has delete a ISBN record");
            return(RedirectToAction("ISBNIndex"));
        }
Exemplo n.º 30
0
        public void ConvertObjectToObjectUsingValueOfMethod()
        {
            ISBN.Reset();
            Assert.Equal(new ISBN("123456789"), ConversionService.Convert <ISBN>("123456789"));

            Assert.Equal(2, ISBN.ConstructorCount);
            Assert.Equal(1, ISBN.ValueOfCount);
            Assert.Equal(0, ISBN.ToStringCount);
        }
Exemplo n.º 31
0
        private void btnImprimirCodigoBarras_Click(object sender, System.EventArgs e)
        {
            CodigoBarras codigoBarras;
            switch (cboCodigoBarras.SelectedIndex)
            {
                case 0: codigoBarras = new EAN8(); break;
                case 1: codigoBarras = new EAN13();break;
                case 2: codigoBarras = new CODABAR();break;
                case 3: codigoBarras = new CODE39();break;
                case 4: codigoBarras = new CODE93();break;
                case 5: codigoBarras = new CODE128();break;
                case 6: codigoBarras = new ISBN();break;
                case 7: codigoBarras = new ITF();break;
                case 8: codigoBarras = new MSI();break;
                case 9: codigoBarras = new PDF417();break;
                case 10: codigoBarras = new PLESSEY();break;
                case 11: codigoBarras = new UPCA();break;
                case 12: codigoBarras = new UPCE();break;
                default: codigoBarras = new EAN13();break;
            }

            codigoBarras.Codigo = txtCodigoBarras.Text;

            // fonte
            if (rbtFonteNormal.Checked)
            {
                codigoBarras.Fonte = CodigoBarras.FonteLegenda.Normal;
            }
            else
            {
                codigoBarras.Fonte = CodigoBarras.FonteLegenda.Condensada;
            }

            // largura das barras
            if (rbtFina.Checked)
            {
                codigoBarras.Largura = CodigoBarras.LarguraBarra.Fina;
            }
            else if(rbtMedia.Checked)
            {
                codigoBarras.Largura = CodigoBarras.LarguraBarra.Media;
            }
            else
            {
                codigoBarras.Largura = CodigoBarras.LarguraBarra.Grossa;
            }

            // posicao legenda
            if (rbtCaracteresAbaixoCodigo.Checked)
            {
                codigoBarras.Posicao = CodigoBarras.PosicaoLegenda.Abaixo;
            }
            else if(rbtCaracteresAcimaCodigo.Checked)
            {
                codigoBarras.Posicao = CodigoBarras.PosicaoLegenda.Acima;
            }
            else if(rbtCaracteresAcimaAbaixoCodigo.Checked)
            {
                codigoBarras.Posicao = CodigoBarras.PosicaoLegenda.AcimaAbaixo;
            }
            else
            {
                codigoBarras.Posicao = CodigoBarras.PosicaoLegenda.Nenhuma;
            }

            try
            {
                miniPrinter.Imprimir(codigoBarras);
            }
            catch (BematechException erro)
            {
                MessageBox.Show(erro.Message, "TestMiniPrinter", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }