Example #1
0
        public async Task <IActionResult> Index()
        {
            using (var context = new MCPContext())
            {
                var model = await context.Authors.Include(a => a.Books).AsNoTracking().ToListAsync();

                return(View(model));
            }
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("Title, AuthorId")] Book book)
        {
            using (var context = new MCPContext())
            {
                context.Books.Add(book);
                await context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("FirstName, LastName")] Author author)
        {
            using (var context = new MCPContext())
            {
                context.Add(author);
                await context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
        }
Example #4
0
        public async Task <IActionResult> Index()
        {
            using (var context = new MCPContext())
            {
                var model = await context.mis_prod_routing.AsNoTracking().ToListAsync();

                model = model.OrderBy(x => x.Order_No).ThenBy(n => n.Op_No).ToList();

                return(View(model));
            }
        }
Example #5
0
        public async Task <IActionResult> Create()
        {
            using (var context = new MCPContext())
            {
                var authors = await context.Authors.Select(a => new SelectListItem {
                    Value = a.AuthorId.ToString(),
                    Text  = $"{a.FirstName} {a.LastName}"
                }).ToListAsync();

                ViewBag.Authors = authors;
            }
            return(View());
        }