public async Task <IActionResult> Get()
        {
            const string message = "HealthCheck Status OK";
            await appService.GetAll();

            return(Ok(message));
        }
Пример #2
0
        public async Task <IActionResult> Get()
        {
            var result = await appService.GetAll();

            if (result.Any())
            {
                return(NotFound());
            }

            return(Ok(result));
        }
        /// <summary>
        /// Makes a select list of companies
        /// </summary>
        /// <returns>SelectList of companies</returns>
        private async Task <List <Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> > Companies()
        {
            var companies = await _companyAppService.GetAll();

            if (companies.Any())
            {
                return(companies.Select(x => new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem {
                    Text = x.Name, Value = x.Id.ToString()
                }).ToList());
            }
            return(new List <Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>());
        }
        public async Task <IHttpActionResult> GetAllAsync()
        {
            var collection = await Task.Run(() => _companyAppService.GetAll());

            var readCollection = new List <CompanyRead>();

            foreach (var c in collection)
            {
                var companyRead = new CompanyRead(c);
                readCollection.Add(companyRead);
            }

            return(this.Ok(readCollection));
        }
Пример #5
0
        public IHttpActionResult GetAll()
        {
            try
            {
                var companyDtos   = _companyAppService.GetAll();
                var companyModels = new List <CompanyModel>();

                foreach (var companyDto in companyDtos)
                {
                    companyModels.Add(Mapper.Map <CompanyModel>(companyDto));
                }

                return(Ok(companyModels));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Пример #6
0
        public async Task <IActionResult> Get()
        {
            return(await Task.Run(() =>
            {
                try
                {
                    const string message = "HealthCheck Status OK";
                    //validate Database Connection (read method)
                    appService.GetAll();

                    logger.LogInformation(message);

                    return Ok(message);
                }
                catch (Exception ex)
                {
                    return StatusCode((int)HttpStatusCode.InternalServerError, new { ex.Message });
                }
            }));
        }
        public async Task <CompanyListModel> PrepareCompanyModel()
        {
            var provinces = await _provinceAppService.GetAll();

            var countries = await _countryAppService.GetAll();

            var companies = await _companyAppService.GetAll();

            IEnumerable <SelectListItem> selectListCountry = countries.Select(x => new SelectListItem {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();
            IEnumerable <SelectListItem> selectListProvince = provinces.Select(x => new SelectListItem {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();
            var model = new CompanyListModel()
            {
                Provinces = selectListProvince,
                Countries = selectListCountry,
                Companies = companies
            };

            return(model);
        }
        public async Task <OrderListModel> PrepareEditModel(Guid orderId)
        {
            var model = new OrderListModel();
            var order = await _appService.GetById(orderId);

            model.OrderId        = orderId;
            model.NewOrderNumber = order.Number;
            var customers = await _customerAppService.GetAll();

            model.Customers = customers.Select(x => new SelectListItem {
                Text = x.CompanyName, Value = x.Id.ToString()
            }).ToList();
            model.Customers.FirstOrDefault(x => x.Value == order.CustomerId.ToString()).Selected = true;

            var companies = await _companyAppService.GetAll();

            model.Companies = companies.Select(x => new SelectListItem {
                Text = x.Name, Value = x.Id.ToString()
            }).ToList();
            model.Companies.FirstOrDefault(x => x.Value == order.CompanyId.ToString()).Selected = true;

            //ISSUE
            var address = await _addressAppService.GetAllByCustomerId(order.CustomerId);

            model.Addresses = address.Select(x => new SelectListItem {
                Text = x.StreetAddress, Value = x.Id.ToString()
            }).ToList();
            model.Addresses.FirstOrDefault(x => x.Value == order.CustomerAddressId.ToString()).Selected = true;

            var paymentTypes = await _paymentTypeAppService.GetAll();

            model.PaymentTypes = paymentTypes.Select(x => new SelectListItem {
                Text = x.TypeName, Value = x.Id.ToString()
            }).ToList();
            model.PaymentTypes.FirstOrDefault(x => x.Value == order.PaymentTypeId.ToString()).Selected = true;
            return(model);
        }
Пример #9
0
        //
        // GET: /Companies/

        public ActionResult Index()
        {
            var comp = Mapper.Map <IEnumerable <Company>, IEnumerable <CompanyViewModel> >(_companyApp.GetAll());

            return(View(comp));
        }
 public async Task <IEnumerable <CompanyViewModel> > GetAll()
 {
     return(await appService.GetAll());
 }
Пример #11
0
        // GET api/apicompanies
        public IEnumerable <CompanyViewModel> Get()
        {
            var comp = Mapper.Map <IEnumerable <Company>, IEnumerable <CompanyViewModel> >(_companyApp.GetAll());

            return(comp);
        }
Пример #12
0
        public async Task Should_Get_All_Companies()
        {
            var result = await _companyAppService.GetAll(new Portal.Companies.Dto.GetAllFilterCompany());

            result.Items.Count.ShouldBe(3);
        }
Пример #13
0
 public async Task <IActionResult> Get()
 {
     return(Ok(await appService.GetAll()));
 }