public IActionResult GetById(long id)
        {
            var item = _custRepo.Find(id);

            if (item == null)
            {
                return(NotFound());
            }
            return(new ObjectResult(item));
        }
Esempio n. 2
0
 public CartWithCustomerInfo GetShoppingCartRecordsWithCustomer(int customerId)
 {
     return(new CartWithCustomerInfo()
     {
         CartRecords = GetShoppingCartRecords(customerId).ToList(),
         Customer = _customerRepo.Find(customerId)
     });
 }
Esempio n. 3
0
        public ActionResult <Customer> Get(int id)
        {
            var item = _repo.Find(id);

            if (item == null)
            {
                return(NotFound());
            }
            return(Ok(item));
        }
Esempio n. 4
0
        public IActionResult Get(int id)
        {
            var item = _repo.Find(id);

            if (item == null)
            {
                return(NotFound());
            }
            return(new ObjectResult(item));
        }
Esempio n. 5
0
        public ActionResult <Customer> Get(int id)
        {
            Customer customer = _repo.Find(id);

            if (customer == null)
            {
                return(NotFound());
            }
            return(Ok(customer));
        }
Esempio n. 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());
            }
        }
        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));
        }
Esempio n. 8
0
 public CartWithCustomerInfo GetShoppingCartRecordsWithCustomer(int customerId)
 => new CartWithCustomerInfo()
 {
     cartRecord = GetShoppingCartRecords(customerId).ToList(),
     Customer   = _customerRepo.Find(customerId)
 };
 public Customer Find(int id)
 {
     return(_customerRepo.Find(id));
 }