コード例 #1
0
        public IActionResult GetById(long id)
        {
            var item = _custRepo.Find(id);

            if (item == null)
            {
                return(NotFound());
            }
            return(new ObjectResult(item));
        }
コード例 #2
0
ファイル: ShoppingCartRepo.cs プロジェクト: KRob314/Samples
 public CartWithCustomerInfo GetShoppingCartRecordsWithCustomer(int customerId)
 {
     return(new CartWithCustomerInfo()
     {
         CartRecords = GetShoppingCartRecords(customerId).ToList(),
         Customer = _customerRepo.Find(customerId)
     });
 }
コード例 #3
0
        public ActionResult <Customer> Get(int id)
        {
            var item = _repo.Find(id);

            if (item == null)
            {
                return(NotFound());
            }
            return(Ok(item));
        }
コード例 #4
0
        public IActionResult Get(int id)
        {
            var item = _repo.Find(id);

            if (item == null)
            {
                return(NotFound());
            }
            return(new ObjectResult(item));
        }
コード例 #5
0
        public ActionResult <Customer> Get(int id)
        {
            Customer customer = _repo.Find(id);

            if (customer == null)
            {
                return(NotFound());
            }
            return(Ok(customer));
        }
コード例 #6
0
        public async Task <IActionResult> GetCustomer([FromRoute] int id)
        {
            if (await CustomerExists(id))
            {
                var customer = await _customerRepository.Find(id);

                return(Ok(customer));
            }
            else
            {
                return(NotFound());
            }
        }
コード例 #7
0
        public IActionResult Index([FromServices] ICustomerRepo customerRepo, int customerId)
        {
            ViewBag.Title  = "Cart";
            ViewBag.Header = "Cart";
            var cartItems = _shoppingCartRepo.GetShoppingCartRecords(customerId);
            var customer  = customerRepo.Find(customerId);
            var mapper    = _config.CreateMapper();
            var viewModel = new CartViewModel
            {
                Customer    = customer,
                CartRecords = mapper.Map <IList <CartRecordViewModel> >(cartItems)
            };

            return(View(viewModel));
        }
コード例 #8
0
 public CartWithCustomerInfo GetShoppingCartRecordsWithCustomer(int customerId)
 => new CartWithCustomerInfo()
 {
     cartRecord = GetShoppingCartRecords(customerId).ToList(),
     Customer   = _customerRepo.Find(customerId)
 };
コード例 #9
0
 public Customer Find(int id)
 {
     return(_customerRepo.Find(id));
 }