示例#1
0
        // GET: ServiceProvider
        public ActionResult Index()
        {
            var model  = new IndexProviderViewModel();
            var names  = new List <string>();
            var cities = new List <string>();

            var providers = providerRepo.ResultTable.ToList();
            var addresses = addressRepo.ResultTable.ToList();

            foreach (var provider in providers)
            {
                var currItem = new IndexItem();
                currItem.ProviderId       = provider.Id;
                currItem.OrganizationName = provider.OrganizationName;
                var currAddress = addresses.Where(a => a.Id == provider.AddressId);
                currItem.City = currAddress.First().City;
                model.ServiceProviders.Add(currItem);
            }

            return(View(model));
        }
示例#2
0
        public IEnumerable <IndexProviderViewModel> GetProviders([FromRoute] int companyId)
        {
            List <Provider> providers          = _context.Providers.Where(x => x.Enabled == true && x.CompanyId == companyId).Include(x => x.Cities).ToList();
            List <IndexProviderViewModel> list = new List <IndexProviderViewModel>();

            foreach (var item in providers)
            {
                IndexProviderViewModel model = new IndexProviderViewModel
                {
                    Address        = item.Address,
                    CountryId      = item.CountryId,
                    StateId        = item.StateId,
                    CityId         = item.CityId,
                    City           = item.Cities?.Description,
                    DateInitial    = item.DateInitial,
                    Documento      = item.Documento,
                    DocumentTypeId = item.DocumentTypeId,
                    Email          = item.Email,
                    Enabled        = item.Enabled,
                    Favorite       = item.Favorite,
                    Id             = item.Id,
                    Observation    = item.Observation,
                    Phone          = item.Phone,
                    RazonSocial    = item.RazonSocial,
                    WebSite        = item.WebSite
                };

                if (!string.IsNullOrEmpty(item.Logo))
                {
                    byte[] imageArray = System.IO.File.ReadAllBytes(@item.Logo);
                    string base64ImageRepresentation = Convert.ToBase64String(imageArray);
                    model.Logo = "data:image/png;base64," + base64ImageRepresentation;
                }

                list.Add(model);
            }

            return(list.OrderBy(x => x.RazonSocial));
        }