示例#1
0
        public IEnumerable <BookCategory> Get()
        {
            var GetAllBaseCategories = _awsomeDbOperation.GetData("GetAllBaseCategories");

            List <BookCategory> bkct = new List <BookCategory>();

            while (GetAllBaseCategories.Read())
            {
                bkct.Add(GetBookCategory(Convert.ToInt32(GetAllBaseCategories["Id"])));
            }

            return(bkct);
        }
示例#2
0
        public IEnumerable <Books> Get(int?categoryId = null)
        {
            if (categoryId != null)
            {
                return(GetAllBooksByCategory((int)categoryId));
            }

            var GetAllBooks = _awsomeDbOperation.GetData("GetAllBooks");

            List <Books> bk = new List <Books>();

            while (GetAllBooks.Read())
            {
                bk.Add(GetBook(Convert.ToInt32(GetAllBooks["Id"])));
            }

            return(bk);
        }
示例#3
0
        //POST api/<AuthorsController>
        //[HttpPost]
        //public void Post([FromBody] string value)
        //{
        //}

        //PUT api/<AuthorsController>/5
        //[HttpPut("{id}")]
        //public void Put(int id, [FromBody] string value)
        //{
        //}

        //DELETE api/<AuthorsController>/5
        //[HttpDelete("{id}")]
        //public void Delete(int id)
        //{
        //}

        protected Authors GetAuthor(int id)
        {
            var Author = _awsomeDbOperation.GetData("GetAuthorById", new SqlParameter[] { new SqlParameter("@Id", id) });

            if (Author.Read())
            {
                return(new Authors
                {
                    Id = Convert.ToInt32(Author["Id"]),
                    Name = Author["Name"].ToString(),
                    Surname = Author["Surname"].ToString(),
                    Biography = Author["Biography"].ToString()
                });
            }

            return(null);
        }