Пример #1
0
        public async Task ShouldCallTheSelectAsyncMethod_WhenGetAllMethodIsCalled()
        {
            ProviderService service = CreateServiceMock();

            var result = await service.GetAll();

            _repositoryMock.Verify(repo => repo.SelectAsync(), Times.Once());
        }
        public async Task <ActionResult> GetAll()
        {
            var apiRep    = new APIResponse();
            var providers = await _providerService.GetAll();

            apiRep.Error = false;
            apiRep.Data  = providers;
            return(Ok(apiRep));
        }
Пример #3
0
 public ActionResult <IEnumerable <ProviderDTO> > Get()
 {
     try
     {
         var results = service.GetAll().ToList();
         return(Ok(mapper.Map <IEnumerable <ProviderDTO> >(results)));
     }
     catch
     {
         return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
     }
 }
Пример #4
0
        public async Task <IActionResult> Edit(int?id, CancellationToken cancellationToken)
        {
            var order = await OrderService.Get(id, cancellationToken);

            var orderItems = await OrderItemsService.GetAllForOrder(order.Id, cancellationToken);

            var showModel = ShowViewModel.Create(order, orderItems);

            ViewBag.Providers = await ProviderService.GetAll(cancellationToken);

            return(View(showModel));
        }
Пример #5
0
        public async Task <IActionResult> Index(CancellationToken cancellationToken)
        {
            var orders = await OrderService.GetAll(cancellationToken);

            var providers = await ProviderService.GetAll(cancellationToken);

            var orderItems = await OrderItemsService.GetAll(cancellationToken);

            var model = IndexViewModel.Create(orders, orders, providers, orderItems);

            return(base.View(model));
        }
 public ActionResult <IEnumerable <ProviderDTO> > Get()
 {
     try
     {
         var result = service.GetAll();
         return(mapper.Map <IEnumerable <ProviderDTO> >(result).ToList());
     }
     catch (Exception)
     {
         return(StatusCode(500));
     }
 }
Пример #7
0
        private IEnumerable <Option> GetProviders()
        {
            var result = _providerService.GetAll();

            if (result.IsSuccess())
            {
                var list = from p in result.GetPayload()
                           select new Option(p.Id.ToString(), p.Country + " - " + p.Name);

                return(list.ToList());
            }

            return(new List <Option>());
        }
Пример #8
0
        private async Task <bool> getProviders()
        {
            var service = new ProviderService(_configuration);

            var response = await service.GetAll();

            if (response != null)
            {
                Parallel.ForEach(response, category =>
                {
                    this._providersSource.AddOrUpdate(category);
                });

                return(true);
            }

            return(false);
        }
Пример #9
0
        // GET
        public IActionResult Index()
        {
            var result = _providerService.GetAll();

            IndexViewModel model;

            if (result.HasErrors())
            {
                model = new IndexViewModel()
                {
                    Providers = new List <Provider>(),
                    Message   = result.GetFailure()
                };

                return(View(model));
            }

            model = new IndexViewModel()
            {
                Providers = result.GetPayload()
            };

            return(View(model));
        }
Пример #10
0
        // GET: Provider
        public ActionResult Index()
        {
            var model = p.GetAll();

            return(View(model));
        }
Пример #11
0
 // GET: Provider/getProviders
 public ActionResult getProviders()
 {
     return(View(p.GetAll()));
 }