/// <summary> /// Prepare paged category list model /// </summary> /// <param name="searchModel">Category search model</param> /// <returns>Category list model</returns> public virtual CompanyListModel PrepareCompanyListModel(CompanySearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get companies var companies = _companyService.GetAllCompanies(companyName: searchModel.SearchCompanyName, showHidden: true, pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize); //prepare grid model var model = new CompanyListModel().PrepareToGrid(searchModel, companies, () => { return(companies.Select(company => { //fill in model values from the entity var companyModel = company.ToModel <CompanyModel>(); //fill in additional values (not existing in the entity) //categoryModel.Breadcrumb = _companyService.GetFormattedBreadCrumb(company); //categoryModel.SeName = _urlRecordService.GetSeName(company, 0, true, false); return companyModel; })); }); return(model); }
public IQueryable <Company> Search(CompanySearchModel searchModel) { DataContext dc = new DataContext(this.DbString); ICompanyRepository companyRep = new CompanyRepository(dc); return(companyRep.Search(searchModel)); }
public IPagedList <Company> GetCompanies(CompanyList page, CompanySearchModel model) { var query = _session.QueryOver <Company>() .Where(a => a.Parent == page); //if (!String.IsNullOrEmpty(model.Category)) //{ // Tag tagAlias = null; // query = query.JoinAlias(article => article.Tags, () => tagAlias).Where(() => tagAlias.Name.IsInsensitiveLike(model.Category, MatchMode.Exact)); //} //if (model.Month.HasValue) //{ // query = // query.Where( // article => article.PublishOn != null && article.PublishOn.Value.MonthPart() == model.Month); //} //if (model.Year.HasValue) //{ // query = // query.Where( // article => article.PublishOn != null && article.PublishOn.Value.YearPart() == model.Year); //} return(query.OrderBy(x => x.Name).Asc.ThenBy(x => x.PublishOn).Desc.Paged(model.Page, page.PageSize)); }
private void SetCompanyList(int?type, bool allowBlank = true) { ICompanyService cs = new CompanyService(Settings.Default.db); CompanySearchModel csm = new CompanySearchModel(); List <Company> companies = cs.Search(csm).ToList(); List <SelectListItem> select = new List <SelectListItem>(); if (allowBlank) { select.Add(new SelectListItem { Text = "", Value = "" }); } foreach (var company in companies) { if (type.HasValue && type.ToString().Equals(company.id)) { select.Add(new SelectListItem { Text = company.name, Value = company.id.ToString(), Selected = true }); } else { select.Add(new SelectListItem { Text = company.name, Value = company.id.ToString(), Selected = false }); } } ViewData["companyList"] = select; }
public async Task <List <CompanyCreateModel> > GetAllCompanies(CompanySearchModel Model) { try { List <CompanyCreateModel> res = null; switch (Model.companyType) { case "MSP": List <tblMSPDetail> dataMSP = await Task.Run(() => ManageMSP.GetAllMSPDetails(Model)); res = dataMSP.Select(a => a.ConvertTocompany()).ToList(); break; case "Customer": List <tblCustomer> dataCustomer = await Task.Run(() => ManageCustomer.GetAllCustomerDetails(Model)); res = dataCustomer.Select(a => a.ConvertTocompany()).ToList(); break; case "Supplier": List <tblSupplier> dataSupplier = await Task.Run(() => ManageSupplier.GetAllSupplierDetails(Model)); res = dataSupplier.Select(a => a.ConvertTocompany()).ToList(); break; } return(res); } catch (Exception) { throw; } }
internal static async Task <List <tblSupplier> > GetAllSupplierDetails(CompanySearchModel model) { try { using (db = new eMSPEntities()) { if (model.companyName == "%") { return(await Task.Run(() => db.tblSuppliers .Include(a => a.tblCountry) .Include(b => b.tblCountryState) .Select(x => x).OrderByDescending(x => x.ID).ToList())); } else { return(await Task.Run(() => db.tblSuppliers .Include(a => a.tblCountry) .Include(b => b.tblCountryState) .Where(x => x.Name == model.companyName).OrderByDescending(x => x.ID).ToList())); } } } catch (Exception) { throw; } }
public async Task <ActionResult <object> > SearchCompanies([FromBody] CompanySearchModel search) { IQueryable <Company> companies = null; if (search.keyword != null) { companies = _context.Companies.Include(c => c.Employees).Where(c => c.Name.Contains(search.keyword) || c.Employees.Any(e => e.FirstName.Contains(search.keyword)) || c.Employees.Any(e => e.LastName.Contains(search.keyword)) ); } if (companies.Count() > 0 && search.EmployeeDateOfBirthFrom != null) { companies = companies?.Where(c => c.Employees.Any(e => e.DateOfBirth > search.EmployeeDateOfBirthFrom)); } if (companies.Count() > 0 && search.EmployeeDateOfBirthTo != null) { companies = companies?.Where(c => c.Employees.Any(e => e.DateOfBirth < search.EmployeeDateOfBirthTo)); } if (companies.Count() > 0 && search.EmployeeJobTitles != null && search.EmployeeJobTitles.Count > 0) { companies = companies?.Where(c => c.Employees.Any(e => search.EmployeeJobTitles.Contains(e.JobTitle.Value))); } if (companies.Count() == 0) { return(new { Results = new int[0] }); } return(new { Results = companies.ToList() }); }
public async Task <string> SearchCompany(CompanySearchModel model) { string defaultSort = "CompanyName ASC"; string sortType = model.IsSortDesc ? "DESC" : "ASC"; string sortField = ValidateUtils.IsNullOrEmpty(model.SortField) ? defaultSort : $"{model.SortField} {sortType}"; var query = _AdministratorRepository.GetManyAsNoTracking(x => (ValidateUtils.IsNullOrEmpty(model.AdminUserName) || x.UserName == model.AdminUserName)) .Select(x => new { x.Id, x.UserName, }) .Join(_CompanyRepository.GetManyAsNoTracking(x => (ValidateUtils.IsNullOrEmpty(model.Address) || x.Address.ToUpper().Contains(model.AdminUserName.ToUpper())) && (ValidateUtils.IsNullOrEmpty(model.Capital) || x.Capital.ToUpper().Contains(model.Capital.ToUpper())) && (ValidateUtils.IsNullOrEmpty(model.CompanyName) || x.CompanyName.ToUpper().Contains(model.CompanyName.ToUpper())) ), x => x.Id, y => y.AdminId, (x, y) => new CompanyViewSearchModel { AdminUserName = x.UserName, Address = y.Address, Capital = y.Capital, CompanyId = y.Id, CompanyName = y.CompanyName, OptionPoll = y.OptionPoll, TotalShares = y.TotalShares }).OrderBy(sortField); var count = await query.CountAsync(); var result = query.Skip((model.Page - 1) * model.PageSize) .Take(model.PageSize) .ToList(); return(ApiResponse.Ok(result, count)); }
public JsonResult GetCompanyAndDepartment() { ICompanyService cs = new CompanyService(Settings.Default.db); CompanySearchModel csm = new CompanySearchModel(); List <Company> companies = cs.Search(csm).ToList(); IDepartmentService ds = new DepartmentService(Settings.Default.db); Dictionary <string, Dictionary <string, string> > departments = new Dictionary <string, Dictionary <string, string> >(); foreach (var company in companies) { List <Department> deps = ds.FindByCompanyId(company.id).ToList(); Dictionary <string, string> department = new Dictionary <string, string>(); if (deps.Count > 0) { department.Add(string.Empty, string.Empty); } foreach (var dep in deps) { department.Add(dep.id.ToString(), dep.name); } departments.Add(company.id.ToString(), department); } return(Json(departments, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Search the companies /// </summary> /// <param name="si"></param> /// <param name="model"></param> /// <returns></returns> public JqGridSearchOut SearchCompanies(JqSearchIn si, CompanySearchModel model) { var data = SearchCompanies(model); var companies = Maps(data); return(si.Search(companies)); }
public async Task <IActionResult> Get([FromQuery] CompanySearchModel search) { var companies = await _companiesRepository.FindManyAsync( new string[] { "Phones", "Address", "Email" }, search.GetSearchExpressions()); return(ActionResultUtil.WrapOrNotFound(companies)); }
/// <summary> /// Search companies /// </summary> /// <param name="model"></param> /// <returns></returns> private IQueryable <Company> SearchCompanies(CompanySearchModel model) { return(Fetch(company => (string.IsNullOrEmpty(model.Keyword) || (!string.IsNullOrEmpty(company.Name) && company.Name.Contains(model.Keyword)) || (!company.CompanyTypeId.HasValue && !string.IsNullOrEmpty(company.CompanyType.Name) && company.CompanyType.Name.Contains(model.Keyword))) && (!model.CompanyTypeId.HasValue || company.CompanyTypeId == model.CompanyTypeId))); }
/// <summary> /// Export companies /// </summary> /// <param name="si"></param> /// <param name="gridExportMode"></param> /// <param name="model"></param> /// <returns></returns> public HSSFWorkbook Exports(JqSearchIn si, GridExportMode gridExportMode, CompanySearchModel model) { var data = gridExportMode == GridExportMode.All ? GetAll() : SearchCompanies(model); var companies = Maps(data); var exportData = si.Export(companies, gridExportMode); return(ExcelUtilities.CreateWorkBook(exportData)); }
public ActionResult <IEnumerable <CompanyDetailsModel> > Index(string searchTerm = null) { var search = new CompanySearchModel(); search.Term = searchTerm; var response = manager.GetIndexModel(search); return(Ok(response)); }
/// <summary> /// Export companies /// </summary> /// <param name="si"></param> /// <param name="gridExportMode"></param> /// <param name="model"></param> /// <returns></returns> public ActionResult Exports(JqSearchIn si, GridExportMode gridExportMode, CompanySearchModel model) { var workbook = _companyService.Exports(si, gridExportMode, model); var output = new MemoryStream(); workbook.Write(output); return(File(output.ToArray(), "application/vnd.ms-excel", "Companies.xls")); }
public IQueryable <Company> Search(CompanySearchModel searchModel) { IQueryable <Company> companies = this.context.Company; if (!string.IsNullOrEmpty(searchModel.Name)) { companies = companies.Where(c => c.name.Contains(searchModel.Name.Trim())); } return(companies); }
public async Task <IHttpActionResult> GetCompanies(CompanySearchModel data) { try { return(Ok(await CompanyService.GetAllCompanies(data))); } catch (Exception) { throw; } }
public virtual async Task <IActionResult> List(CompanySearchModel searchModel) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageCategories)) { return(await AccessDeniedDataTablesJson()); } //prepare model var model = await _companyModelFactory.PrepareCompanyListModelAsync(searchModel); return(Json(model)); }
public virtual IActionResult List(CompanySearchModel searchModel) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories)) { return(AccessDeniedDataTablesJson()); } //prepare model var model = _companyModelFactory.PrepareCompanyListModel(searchModel); return(Json(model)); }
public async Task <ResponseModel <List <CompanyViewSearchModel> > > SearchCompany( [FromQuery] CompanySearchModel model) { var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var result = await _companyService.SearchCompany(userId, model); Response.StatusCode = (int)HttpStatusCode.OK; return(new ResponseBuilder <List <CompanyViewSearchModel> >() .Success() .Data(result) .Count(result.Count) .build()); }
private void SearchOrders(CompanyManageViewModel model) { using (UnitOfWorkManager.NewUnitOfWork()) { var searchModel = new CompanySearchModel { PageIndex = model.PageIndex, PageSize = model.PageSize, KeyWord = model.KeyWord }; model.ViewList = _companyService.Search(searchModel); } }
internal static async Task <List <tblMSPDetail> > GetAllMSPDetails(CompanySearchModel model) { try { using (db = new eMSPEntities()) { return(await Task.Run(() => db.tblMSPDetails.Where(x => x.CompanyName == model.companyName).OrderByDescending(x => x.ID).ToList())); } } catch (Exception) { throw; } }
public ActionResult Index(int?page) { int pageIndex = PagingHelper.GetPageIndex(page); CompanySearchModel q = new CompanySearchModel(); ICompanyService ss = new CompanyService(Settings.Default.db); IPagedList <Company> companies = ss.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize); ViewBag.Query = q; return(View(companies)); }
public ActionResult Search([Bind(Include = "Name")] CompanySearchModel q) { int pageIndex = 0; int.TryParse(Request.QueryString.Get("page"), out pageIndex); pageIndex = PagingHelper.GetPageIndex(pageIndex); ICompanyService ss = new CompanyService(Settings.Default.db); IPagedList <Company> companies = ss.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize); ViewBag.Query = q; return(View("Index", companies)); }
/// <summary> /// Prepare category search model /// </summary> /// <param name="searchModel">Category search model</param> /// <returns>Category search model</returns> public virtual CompanySearchModel PrepareCompanySearchModel(CompanySearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //prepare available stores _baseAdminModelFactory.PrepareStores(searchModel.AvailableCompanies); //searchModel.HideStoresList = _catalogSettings.IgnoreStoreLimitations || searchModel.AvailableCompanies.SelectionIsNotPossible(); //prepare page parameters searchModel.SetGridPageSize(); return(searchModel); }
public IPagedList <Company> Search(CompanySearchModel searchModel) { var query = _context.Company.Where(x => (x.Deleted == false) && (string.IsNullOrEmpty(searchModel.KeyWord) || x.CompanyName.ToLower().Contains(searchModel.KeyWord) || x.CompanyAddress.ToLower().Contains(searchModel.KeyWord) || x.ContactPerson.ToLower().Contains(searchModel.KeyWord) || x.ContactPhone.ToLower().Contains(searchModel.KeyWord) || x.LegalPerson.ToLower().Contains(searchModel.KeyWord) //|| x.MembershipUser.Username .ToLower().Contains (searchModel.KeyWord ) //|| x.MembershipUser.Email.ToLower().Contains (searchModel.KeyWord ) ) ) .OrderBy(x => x.CompanyName); var count = query.Count(); var result = query.Skip((searchModel.PageIndex - 1) * searchModel.PageSize).Take(searchModel.PageSize).ToList(); return(new PagedList <Company>(result, searchModel.PageIndex, searchModel.PageSize, count)); }
public virtual async Task <CompanyListModel> PrepareCompanyListModelAsync(CompanySearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get categories var companies = await _companyService.GetAllCompaniesAsync(name : searchModel.SearchCompanyName, pageIndex : searchModel.Page - 1, pageSize : searchModel.PageSize); //prepare grid model var model = await new CompanyListModel().PrepareToGridAsync(searchModel, companies, () => { return(companies.SelectAwait(async company => { var customer = await _workContext.GetCurrentCustomerAsync(); //fill in model values from the entity var companyModel = company.ToModel <CompanyModel>(); return companyModel; })); }); return(model); }
public virtual async Task <CompanySearchModel> PrepareCompanySearchModelAsync(CompanySearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } var customer = await _workContext.GetCurrentCustomerAsync(); //prepare page parameters searchModel.SetGridPageSize(); return(searchModel); }
public IEnumerable <CompanyDetailsModel> GetIndexModel(CompanySearchModel search) { throw new NotImplementedException(); }
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)); }