[HttpGet("", Name = "GetCustomers")] //  ./api/customers
        public IActionResult GetAll([FromQuery] CustomerListParameters listParameters)
        {
            if (listParameters.Page < 1)
            {
                return(UnprocessableEntity(new ValidationFailedResult("Page must be 1 or greater.")));
            }
            if (listParameters.Take < 1)
            {
                return(UnprocessableEntity(new ValidationFailedResult("Take must be 1 or greater.")));
            }
            if (listParameters.Take > 500)
            {
                return(UnprocessableEntity(new ValidationFailedResult("Take cannot be larger than 500.")));
            }

            var customers = _customerData.GetAll(listParameters);
            var models    = customers.Select(c => new CustomerDisplayViewModel(c));

            var pagination = new PaginationModel
            {
                Previous = CreateCustomersResourceUri(listParameters, -1),
                Next     = CreateCustomersResourceUri(listParameters, 1)
            };

            Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(pagination));

            return(Ok(models));
        }
Esempio n. 2
0
        public IActionResult Index()
        {
            var model = new HomePageViewModel();

            model.Customers = _customerData.GetAll();
            return(View(model));
        }
Esempio n. 3
0
 public Order_Edit(ICustomerData customerData, IEmployeeData employeeData, IStatusData statusData, Order order)
 {
     Order     = order;
     Customers = customerData.GetAll();
     Employees = employeeData.GetAll();
     Statuses  = statusData.GetAll();
 }
        public ActionResult Create()
        {
            var model = new Application
            {
                Customers = customerDb.GetAll()
            };

            return(View(model));
        }
Esempio n. 5
0
        public ActionResult Create()
        {
            var model = new CustomerContract
            {
                Customers = customerDb.GetAll()
            };

            model.StartDate   = DateTime.Today;
            model.PaymentDate = DateTime.Today;
            return(View(model));
        }
Esempio n. 6
0
 public async Task <IEnumerable <CustomerViewModel> > Get()
 {
     return(_mapper.Map <IEnumerable <CustomerViewModel> >(await _customerData.GetAll()));
 }
Esempio n. 7
0
 public Customer_Index(ICustomerData customerData) : base()
 {
     Customers = customerData.GetAll();
 }