Example #1
0
        static void Main(string[] args)
        {
            var context = new BooksShopContext();
            var books   = context.Books.Count();

            Console.WriteLine(books);
        }
Example #2
0
        // GET api/values/5
        public IHttpActionResult Get(int id)
        {
            var context = new BooksShopContext();
            var author  = context.Authors
                          .Where(a => a.Id == id)
                          .Select(a => "Id: " + a.Id + " - " + a.FirstName + " " + a.LastName);

            return(this.Ok(author));
        }
Example #3
0
        public void Post([FromBody] Author author)
        {
            var context = new BooksShopContext();

            context.Authors.Add(new Author()
            {
                FirstName = author.FirstName,
                LastName  = author.LastName
            });
            context.SaveChanges();
        }