public HttpResponseMessage GetCompanyCoordinates()
        {
            var _Companies = _db.Companies.ToList();
            CompanyCoordinatesModel _CompanyCoordinatesModel = new CompanyCoordinatesModel();

            _CompanyCoordinatesModel.Flag    = "false";
            _CompanyCoordinatesModel.MESSAGE = "Company Coordinates Info";
            if (null != _Companies && _Companies.Count() > 0)
            {
                List <ComapnyCoordinatesDetails> _lstComapnyCoordinates = new List <ComapnyCoordinatesDetails>();
                _CompanyCoordinatesModel.Flag = "true";
                foreach (var comp in _Companies)
                {
                    ComapnyCoordinatesDetails _ComapnyCoordinates = new ComapnyCoordinatesDetails();
                    _ComapnyCoordinates.CompanyId     = comp.CompanyId;
                    _ComapnyCoordinates.CompanyName   = comp.CompanyName;
                    _ComapnyCoordinates.PartnerType   = comp.PartnerType;
                    _ComapnyCoordinates.StreetAddress = comp.StreetAddress;
                    _ComapnyCoordinates.City          = comp.City;
                    _ComapnyCoordinates.State         = comp.State;
                    _ComapnyCoordinates.ZipCode       = comp.ZipCode;
                    _ComapnyCoordinates.Phone1        = comp.Phone1;
                    _ComapnyCoordinates.Phone2        = comp.Phone2;
                    _ComapnyCoordinates.Description   = string.IsNullOrEmpty(comp.Description) ? "Description is not available." : comp.Description;
                    _ComapnyCoordinates.IsFavourite   = false;
                    _ComapnyCoordinates.Latitude      = null == comp.Latitude ? 0 : comp.Latitude;
                    _ComapnyCoordinates.Longitude     = null == comp.Longitude ? 0 : comp.Longitude;
                    List <CompanyCategories> lstCompCat = new List <CompanyCategories>();
                    var companycatategories             = _db.CompanyCategories.Where(a => a.CompanyId == comp.CompanyId).ToList();
                    if (null != companycatategories && companycatategories.Count() > 0)
                    {
                        foreach (var cat in companycatategories)
                        {
                            CompanyCategories _CompCat = new CompanyCategories();
                            var categoryname           = _db.Categories.FirstOrDefault(c => c.CategoryId == cat.CategoryId);
                            _CompCat.CategoryId   = cat.CategoryId;
                            _CompCat.CategoryName = categoryname.Category1;
                            lstCompCat.Add(_CompCat);
                        }
                    }
                    _ComapnyCoordinates.CompanyCategories = lstCompCat;

                    _lstComapnyCoordinates.Add(_ComapnyCoordinates);
                }
                _CompanyCoordinatesModel.ComapnyCoordinates = _lstComapnyCoordinates;
            }
            return(Request.CreateResponse(HttpStatusCode.OK, _CompanyCoordinatesModel));
        }
Exemple #2
0
        public HttpResponseMessage SearchCompanies(string keyword, long?UserId = 0)
        {
            SearchCompanyResponse _CompanyResponse = new SearchCompanyResponse();

            _CompanyResponse.MESSAGE = "Companies";
            _CompanyResponse.Flag    = "false";
            var arrCompanyIds = new List <UserFavorite>();

            if (UserId > 0)
            {
                arrCompanyIds = _db.UserFavorites.Where(a => a.UserId == UserId).ToList();
            }

            var lstCompanies = _db.Companies.Where(m => m.CompanyName.ToLower().Contains(keyword) || m.Description.ToLower().Contains(keyword)).ToList();
            List <CompanySearchModel> lstCompanyVM = new List <CompanySearchModel>();

            if (lstCompanies != null)
            {
                _CompanyResponse.Flag = "true";



                for (int i = 0; i < lstCompanies.Count(); i++)
                {
                    CompanySearchModel _CompanyViewModel = new CompanySearchModel();
                    _CompanyViewModel.CompanyId = lstCompanies[i].CompanyId;
                    int companyid = lstCompanies[i].CompanyId;
                    List <CompanyCategories> lstCompCat = new List <CompanyCategories>();
                    var companycatategories             = _db.CompanyCategories.Where(a => a.CompanyId == companyid).ToList();
                    if (null != companycatategories && companycatategories.Count() > 0)
                    {
                        foreach (var cat in companycatategories)
                        {
                            CompanyCategories _CompCat = new CompanyCategories();
                            var categoryname           = _db.Categories.FirstOrDefault(c => c.CategoryId == cat.CategoryId);
                            _CompCat.CategoryId   = cat.CategoryId;
                            _CompCat.CategoryName = categoryname.Category1;
                            lstCompCat.Add(_CompCat);
                        }
                    }
                    _CompanyViewModel.CompanyCategories = lstCompCat;
                    //_CompanyViewModel.CategoryId = lstCompanies[i].CategoryId;
                    _CompanyViewModel.CompanyName   = lstCompanies[i].CompanyName;
                    _CompanyViewModel.PartnerType   = lstCompanies[i].PartnerType;
                    _CompanyViewModel.StreetAddress = lstCompanies[i].StreetAddress;
                    _CompanyViewModel.City          = lstCompanies[i].City;
                    _CompanyViewModel.ZipCode       = lstCompanies[i].ZipCode;
                    _CompanyViewModel.State         = lstCompanies[i].State;
                    _CompanyViewModel.Phone1        = lstCompanies[i].Phone1;
                    _CompanyViewModel.Phone2        = lstCompanies[i].Phone2;
                    _CompanyViewModel.Description   = string.IsNullOrEmpty(lstCompanies[i].Description) ? "Description is not available." : lstCompanies[i].Description;
                    _CompanyViewModel.IsFavourite   = false;
                    _CompanyViewModel.Latitude      = null == lstCompanies[i].Latitude ? 0 : lstCompanies[i].Latitude;
                    _CompanyViewModel.Longitude     = null == lstCompanies[i].Longitude ? 0 : lstCompanies[i].Longitude;
                    if (null != arrCompanyIds)
                    {
                        bool containsItem = arrCompanyIds.Any(item => item.CompanyId == lstCompanies[i].CompanyId);
                        if (containsItem)
                        {
                            _CompanyViewModel.IsFavourite = true;
                        }
                    }
                    lstCompanyVM.Add(_CompanyViewModel);
                }
            }
            _CompanyResponse.Companies = lstCompanyVM;
            return(Request.CreateResponse(HttpStatusCode.OK, _CompanyResponse));
        }
Exemple #3
0
        public static CompanyDetailsViewModel GetCompanyDetails(Company company)
        {
            CompanyDetailsViewModel _CompanyViewModel = new CompanyDetailsViewModel();

            _CompanyViewModel.CompanyId                    = company.CompanyId;
            _CompanyViewModel.PartnerType                  = "" + company.PartnerType;
            _CompanyViewModel.CompanyName                  = "" + company.CompanyName;
            _CompanyViewModel.StreetAddress                = "" + company.StreetAddress;
            _CompanyViewModel.City                         = "" + company.City;
            _CompanyViewModel.State                        = "" + company.State;
            _CompanyViewModel.ZipCode                      = "" + company.ZipCode;
            _CompanyViewModel.Phone1                       = "" + company.Phone1;
            _CompanyViewModel.Phone2                       = "" + company.Phone2;
            _CompanyViewModel.Website                      = "" + company.Website;
            _CompanyViewModel.FTPSite                      = "" + company.FTPSite;
            _CompanyViewModel.ArtEmail                     = "" + company.ArtEmail;
            _CompanyViewModel.OrderEmail                   = "" + company.OrderEmail;
            _CompanyViewModel.FOBPointInCanada             = "" + company.FOBPointInCanada;
            _CompanyViewModel.QuoteinCanadianDollars       = "" + company.QuoteinCanadianDollars;
            _CompanyViewModel.PrimaryContactFirstName      = "" + company.PrimaryContactFirstName;
            _CompanyViewModel.PrimaryContactLastName       = "" + company.PrimaryContactLastName;
            _CompanyViewModel.PrimaryContactEmail          = "" + company.PrimaryContactEmail;
            _CompanyViewModel.PrimaryContactFax            = "" + company.PrimaryContactFax;
            _CompanyViewModel.PrimaryContactExtension      = "" + company.PrimaryContactExtension;
            _CompanyViewModel.PrimaryContactTradeOnly      = "" + company.PrimaryContactTradeOnly;
            _CompanyViewModel.PrimaryContactDirectLine     = "" + company.PrimaryContactDirectLine;
            _CompanyViewModel.PrimaryContactAffiliations   = "" + company.PrimaryContactAffiliations;
            _CompanyViewModel.SecondaryContactFirstName    = "" + company.SecondaryContactFirstName;
            _CompanyViewModel.SecondaryContactLastName     = "" + company.SecondaryContactLastName;
            _CompanyViewModel.SecondaryContactEmail        = "" + company.SecondaryContactEmail;
            _CompanyViewModel.SecondaryContactExtension    = "" + company.SecondaryContactExtension;
            _CompanyViewModel.SecondaryContactDirectLine   = "" + company.SecondaryContactDirectLine;
            _CompanyViewModel.SecondaryContactFax          = "" + company.SecondaryContactFax;
            _CompanyViewModel.SecondaryContactAffiliations = "" + company.SecondaryContactAffiliations;
            _CompanyViewModel.SecondaryContactTradeOnly    = "" + company.SecondaryContactTradeOnly;
            _CompanyViewModel.TertiaryContactFirstName     = "" + company.TertiaryContactFirstName;
            _CompanyViewModel.TertiaryContactLastName      = "" + company.TertiaryContactLastName;
            _CompanyViewModel.TertiaryContactEmail         = "" + company.TertiaryContactEmail;
            _CompanyViewModel.TertiaryContactFax           = "" + company.TertiaryContactFax;
            _CompanyViewModel.TertiaryContactTradeOnly     = "" + company.TertiaryContactTradeOnly;
            _CompanyViewModel.TertiaryContactDirectLine    = "" + company.TertiaryContactDirectLine;
            _CompanyViewModel.TertiaryContactAffiliations  = "" + company.TertiaryContactAffiliations;
            _CompanyViewModel.Union                        = company.Union;
            _CompanyViewModel.ASI             = company.ASI;
            _CompanyViewModel.PPAI            = company.PPAI;
            _CompanyViewModel.PPPC            = company.PPPC;
            _CompanyViewModel.SAGE            = company.SAGE;
            _CompanyViewModel.UPIC            = company.UPIC;
            _CompanyViewModel.Certifications  = company.Certifications;
            _CompanyViewModel.MinorityOwned   = company.MinorityOwned;
            _CompanyViewModel.ProformaPricing = company.ProformaPricing;
            List <ProformaOffer> lstProformaPrograms = new List <ProformaOffer>();

            if (company.CompanyId > 0)
            {
                var _ProformaPrograms = _db.ProformaPrograms.Where(a => a.CompanyId == company.CompanyId).ToList();
                if (_ProformaPrograms.Count() > 0)
                {
                    foreach (var item in _ProformaPrograms)
                    {
                        if (!string.IsNullOrEmpty(item.Name))
                        {
                            lstProformaPrograms.Add(new ProformaOffer {
                                Offer = item.Name
                            });
                        }
                    }
                }
            }

            //if (!string.IsNullOrEmpty(company.ProformaPrograms))
            //{
            //    var lst = company.ProformaPrograms.Split(new[] { ',', '.' }).ToList();
            //    foreach (var pc in lst)
            //    {
            //        var strProformaOffer = pc.Trim();
            //        if (!string.IsNullOrEmpty(strProformaOffer))
            //        {
            //            lstProformaPrograms.Add(new ProformaOffer { Offer = strProformaOffer });
            //        }
            //    }
            //}
            _CompanyViewModel.ProformaOffers = lstProformaPrograms;

            List <ProductsNCapability> lstProducts = new List <ProductsNCapability>();

            if (company.CompanyId > 0)
            {
                var _ProductsNCapabilities = _db.ProductsCapabilities.Where(a => a.CompanyId == company.CompanyId).ToList();
                if (_ProductsNCapabilities.Count() > 0)
                {
                    foreach (var item in _ProductsNCapabilities)
                    {
                        if (!string.IsNullOrEmpty(item.Name))
                        {
                            lstProducts.Add(new ProductsNCapability {
                                Product = item.Name
                            });
                        }
                    }
                }
            }
            //if (!string.IsNullOrEmpty(company.ProductsNCapabilities))
            //{
            //    var lstProdcutsStrings = company.ProductsNCapabilities.Split(new[] { ',', '.', '\n', ';' }).ToList();
            //    foreach (var p in lstProdcutsStrings)
            //    {
            //        var strProduct = p.Trim();
            //        if (!string.IsNullOrEmpty(strProduct))
            //        {
            //            lstProducts.Add(new ProductsNCapability { Product = strProduct });
            //        }
            //    }
            //}
            _CompanyViewModel.ProductsNCapabilities = lstProducts;

            _CompanyViewModel.Rushor24hour = company.Rushor24hour;
            List <CompanyCategories> lstCompCat = new List <CompanyCategories>();
            var companycatategories             = _db.CompanyCategories.Where(a => a.CompanyId == company.CompanyId).ToList();

            if (null != companycatategories && companycatategories.Count() > 0)
            {
                foreach (var cat in companycatategories)
                {
                    CompanyCategories _CompCat = new CompanyCategories();
                    var categoryname           = _db.Categories.FirstOrDefault(c => c.CategoryId == cat.CategoryId);
                    _CompCat.CategoryId   = cat.CategoryId;
                    _CompCat.CategoryName = categoryname.Category1;
                    lstCompCat.Add(_CompCat);
                }
            }
            _CompanyViewModel.CompanyCategories = lstCompCat;
            //_CompanyViewModel.CategoryId = company.CategoryId;
            _CompanyViewModel.Description = "" + company.Description;
            _CompanyViewModel.Latitude    = null == company.Latitude ? 0 : company.Latitude;
            _CompanyViewModel.Longitude   = null == company.Longitude ? 0 : company.Longitude;

            return(_CompanyViewModel);
        }