Exemple #1
0
        public async Task <dynamic> Get(string companyName)
        {
            if (CheckClientSecret())
            {
                try
                {
                    using (HttpClient client = new HttpClient())
                        using (Entities db = new Entities())
                        {
                            CompanyRoot.Company company = await CompanySearch.GetCompany(client, companyName, db);

                            ContactRoot.Contact contact = await ContactSearch.GetContacts(client, company.Results.FirstOrDefault());

                            return(ContactSearch.CreateContactDTOs(contact));
                        }
                }
                catch (Exception ex)
                {
                    return(ex);
                }
            }
            else
            {
                return(new HttpResponseMessage(System.Net.HttpStatusCode.Forbidden));
            }
        }
        public async Task <dynamic> Get(string companyName)
        {
            if (CheckClientSecret())
            {
                try
                {
                    using (HttpClient client = new HttpClient())
                        using (Entities db = new Entities())
                        {
                            CompanyRoot.Company company = await CompanySearch.GetCompany(client, companyName, db);

                            EngagementsRoot engagementsRoot = await EngagementsSearch.GetEngagements(client, companyName, db, company.Results.FirstOrDefault().Id);

                            List <EngagementsDTO> allEngagementsDTO = new List <EngagementsDTO>();

                            for (int i = 0; i < engagementsRoot.Results.Count; i++)
                            {
                                allEngagementsDTO.Add(new EngagementsDTO(engagementsRoot.Results[i]));
                            }

                            return(allEngagementsDTO);
                        }
                }
                catch (Exception ex)
                {
                    return(ex);
                }
            }
            else
            {
                return(new HttpResponseMessage(HttpStatusCode.Forbidden));
            }
        }
        public Task <IEnumerable <Company> > GetAsync(CompanySearch option, CancellationToken token = default(CancellationToken))
        {
            var query = @"
SELECT      *
FROM        Company cm
WHERE       cm.Id           = cm.Id";

            if (option.Id.HasValue)
            {
                query += @"
AND         cm.Id           = @Id";
            }
            if (!string.IsNullOrEmpty(option.Code))
            {
                query += @"
AND         cm.Code         = @Code";
            }
            if (!string.IsNullOrWhiteSpace(option.Name))
            {
                option.Name = Sql.GetWrappedValue(option.Name);
                query      += @"
AND         cm.Name         LIKE @Name";
            }
            query += @"
ORDER BY    cm.Code         ASC";
            return(dbHelper.GetItemsAsync <Company>(query, option, token));
        }
Exemple #4
0
        public IQueryable <VM.CompanyModel> GetItems(CompanySearch search)
        {
            var result = from company in Ctx.tbl_Company.Where(c => c.IsDeleted != true).DefaultIfEmpty()
                         // join uc in Ctx.tbl_Common_UserOfCompany.Where(c => c.IsDeleted != true) on company.ID equals uc.CompanyId into ucinner
                         // from uci in ucinner.DefaultIfEmpty()
                         // where uci.UserId == search.UserId
                         select new VM.CompanyModel()
            {
                ID               = company.ID,
                Name             = company.Name,
                Code             = company.Code,
                Description      = company.Description,
                CreatedBy        = company.CreatedBy,
                CreatedDate      = company.CreatedDate,
                UpdatedBy        = company.UpdatedBy,
                UpdatedDate      = company.UpdatedDate,
                ProcessingTime   = company.ProcessingTime,
                ProcessingHour   = company.ProcessingTime.Value.Hours,
                ProcessingMinute = company.ProcessingTime.Value.Minutes,
                SendTime         = company.SendTime,
                SendHour         = company.SendTime.Value.Hours,
                SendMinute       = company.SendTime.Value.Minutes,
                SendUrl          = company.SendUrl,
                EmailAddress     = company.EmailAddress,
                Rate             = company.Rate,
                Fee              = company.Fee,
                DocumentMaker    = company.DocumentMaker,
                IsDeleted        = company.IsDeleted
            };

            return(result);
        }
Exemple #5
0
        private ExpressionStarter <Company> GetCompaniesEmployeesFilter(CompanySearch model)
        {
            var predicate = PredicateBuilder.New <Company>(true);

            if (model.EmployeeJobTitles != null && model.EmployeeJobTitles.Count > 0)
            {
                predicate.And(a =>
                              a.Employees.Any(x => model.EmployeeJobTitles.Contains(x.JobTitle)));
            }

            if (model.EmployeeBirthDateFrom.HasValue)
            {
                predicate.And(a =>
                              a.Employees.Any(x => x.BirthDate >= model.EmployeeBirthDateFrom.Value));
            }

            if (model.EmployeeBirthDateTo.HasValue)
            {
                predicate.And(a =>
                              a.Employees.Any(x => x.BirthDate <= model.EmployeeBirthDateTo.Value));
            }

            if (!string.IsNullOrWhiteSpace(model.Keyword))
            {
                predicate.And(a => a.Name.ToLower().Contains(model.Keyword.ToLower()) ||
                              a.Employees.Any(x =>
                                              x.FirstName.ToLower().Contains(model.Keyword.ToLower()) ||
                                              x.LastName.ToLower().Contains(model.Keyword.ToLower())));
            }

            return(predicate);
        }
        public async Task <ActionResult <IEnumerable <Company> > > SearchCompanies([FromBody] CompanySearch search)
        {
            try
            {
                var results = await _companyManager.Search(search);

                if (results.StatusCode == HttpStatusCode.OK)
                {
                    return(Ok(results.Result));
                }
                else if (results.StatusCode == HttpStatusCode.BadRequest)
                {
                    return(BadRequest(results.Message));
                }
                else
                {
                    return(StatusCode((int)HttpStatusCode.InternalServerError, results.Message));
                }
            }
            catch (Exception ex)
            {
                // Log data
                return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Exemple #7
0
        private static void TestVisitors(AbstractCompanyEntity company)
        {
            // Test Company Search
            // Search whole company for any group or employee with an "a" in its name
            CompanySearch client = new CompanySearch(company);

            Console.WriteLine("Enter Search Query: ");
            var results = client.Search(Console.ReadLine());

            Console.WriteLine("\nResults:");
            foreach (var x in results)
            {
                Console.WriteLine(x.Name);
            }
            Console.WriteLine("\nPress enter to continue.\n");
            Console.ReadKey();

            Console.WriteLine("Full Company Structure:\n");
            // Test Printer
            CompanyPrinter.Print(company);
            Console.Write("\nCompany Utilization: ");
            Console.Write(company.Utilization + "\n");

            Console.WriteLine();
        }
Exemple #8
0
        public IActionResult Search([FromBody] CompanySearch search)
        {
            List <Company> companies = this.dbContext.Companies.Include(c => c.Employees).AsEnumerable()
                                       .Where(c => (search.Keyword == null) ||
                                              c.Name == search.Keyword || c.Employees.Any(e => e.FirstName == search.Keyword || e.LastName == search.Keyword))
                                       .Where(c => (search.EmployeeDateOfBirthFrom == null) ||
                                              c.Employees.Exists(e => search.EmployeeDateOfBirthFrom <= e.DateOfBirth))
                                       .Where(c => (search.EmployeeDateOfBirthTo == null) ||
                                              c.Employees.Exists(e => search.EmployeeDateOfBirthTo >= e.DateOfBirth))
                                       .Where(c => (search.EmployeeJobTitles == null) ||
                                              c.Employees.Any(e => search.EmployeeJobTitles.Contains(e.JobTitle)))
                                       .ToList();

            return(Ok(new
            {
                Results = companies.Select(c => new
                {
                    Name = c.Name,
                    EstablishmentYear = c.EstablishmentYear,
                    Employees = c.Employees.Select(e => new
                    {
                        FirstName = e.FirstName,
                        LastName = e.LastName,
                        DateOfBirth = e.DateOfBirth,
                        JobTitle = e.JobTitle
                    })
                })
            }));
        }
Exemple #9
0
        public ActionResult GetList()
        {
            ViewBag.DisplayDate = BasicParam.DatetimeFormat;
            CompanySearch search = new CompanySearch();
            // search.UserId = CommonMethod.getIntValue(UserHelper.GetCurrentUser().Id);
            //  search.RoleId = (int)UserHelper.GetCurrentUser().RoleId;
            var companyModel = BL.GetItems(search);

            return(PartialView("_List", companyModel));
        }
Exemple #10
0
        public IHttpActionResult GetList(CompanySearch search)
        {
            AuthDetails authdet = LoginUserDetails();
            var         filters = new List <MySqlParameter>
            {
                datatableService.CreateSqlParameter("@pUserId", authdet.UserId, MySqlDbType.Int32)
            };
            var result = service.GetList(search, filters);

            return(Ok(result));
        }
Exemple #11
0
 public IList<Company> FindCompanies(CompanySearch searchType, string searchValue)
 {
     switch (searchType)
     {
         case CompanySearch.CompanyName:
             return _companyRepository.FindCompaniesByCompanyName(searchValue);
         case CompanySearch.ABN:
             return _companyRepository.FindCompaniesByABN(searchValue);
         default:
             return new List<Company>();
     }
 }
        public ActionResult <List <Company> > GetCompanySearch(CompanySearch companySearch)
        {
            List <Company> companySearchResult = new List <Company>();

            try
            {
                companySearchResult = _context.Company
                                      .GroupJoin(_context.Employee,
                                                 Company => Company.CompanyId,
                                                 Employee => Employee.Idcompany,
                                                 (x, y) =>
                                                 new
                {
                    Company  = x,
                    Employee = y
                })
                                      .SelectMany(xy =>
                                                  xy.Employee.DefaultIfEmpty(),
                                                  (x, y) =>
                                                  new
                {
                    x.Company,
                    Employee = y
                })
                                      .Where(e =>
                                             CheckIfItemIsNull <string>(companySearch.Keyword) ||
                                             (companySearch.Keyword == e.Company.CompanyName ||
                                              companySearch.Keyword == e.Employee.FirstName ||
                                              companySearch.Keyword == e.Employee.LastName)
                                             )
                                      .Where(e =>
                                             CheckIfItemIsNull <DateTime?>(companySearch.EmployeeDateOfBirthFrom) ||
                                             companySearch.EmployeeDateOfBirthFrom <= e.Employee.DateOfBirth
                                             )
                                      .Where(e =>
                                             CheckIfItemIsNull <DateTime?>(companySearch.EmployeeDateOfBirthTo) ||
                                             companySearch.EmployeeDateOfBirthTo > e.Employee.DateOfBirth
                                             )
                                      .Where(e =>
                                             CheckIfItemIsNull <List <string> >(companySearch.EmployeeJobTitles) ||
                                             companySearch.EmployeeJobTitles.Contains(e.Employee.JobTitle)
                                             )
                                      .Select(s =>
                                              s.Company
                                              )
                                      .ToList();
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.InnerException.Message));
            }
            return(companySearchResult);
        }
        public ActionResult FilterCompanys([DataSourceRequest] DataSourceRequest request, string companyName)
        {
            ViewBag.ScreenWidth = Request.Browser.ScreenPixelsWidth;
            var companySearch = new CompanySearch {
                CompanyName = companyName
            };

            Session["companySearch"] = companySearch;
            DataSourceResult result = service.SearchCompanySetItems(companySearch).ToDataSourceResult(request);

            return(Json(result));
        }
Exemple #14
0
 public DataTable <CompanyDatatable> GetList(CompanySearch search, List <MySqlParameter> filters)
 {
     try
     {
         using (var ctx = new AppDb())
         {
             var result = datatableService.GetDataTableResult <CompanyDatatable>("company_list_sp", search, filters);
             return(result);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #15
0
        public async Task Get_Companies_Employees_Without_Search()
        {
            //Arrange
            var searchModel = new CompanySearch();

            //Act
            var companyResult = await CompanyRepository.AddAsync(_newCompany);

            var companies = await CompanyRepository.GetCompaniesEmployeesAsync(searchModel);

            await CompanyRepository.DeleteAsync(companyResult.Id);

            //Assert
            Assert.IsTrue(companies.Count > 0);
        }
        public IActionResult Search([FromForm] CompanySearch company)
        {
            var listCompany           = _enterpriseService.getListEnt(company.CompanyName, company.Address, company.Page);
            List <CompanyModel> model = new List <CompanyModel>();

            listCompany.ForEach(c =>
            {
                model.Add(new CompanyModel()
                {
                    EntID       = c.ID,
                    CompanyName = c.EnterpriseInfo.Company_Name,
                    Area        = c.EnterpriseInfo.Area,
                    Email       = c.EnterpriseInfo.Email
                });
            });
            var tupleModel = new Tuple <List <CompanyModel>, CompanySearch>(model, company);

            return(View(tupleModel));
        }
Exemple #17
0
        public IEnumerable <Company> Search(CompanySearch searchCriteria)
        {
            var dbCompanies =
                _dbSet
                .AsQueryable()
                .Include(e => e.Address)
                .Include(e => e.BankAccount)
                .Include(e => e.BankAccount.Currency_SDIC)
                .Where(e => (string.IsNullOrEmpty(searchCriteria.Name) || e.Name.Contains(searchCriteria.Name)) &&
                       (string.IsNullOrEmpty(searchCriteria.Symbol) || e.Symbol.Contains(searchCriteria.Symbol)) &&
                       (string.IsNullOrEmpty(searchCriteria.FreeText) || true));

            bool isAsc = searchCriteria.SortType == (int)Enums.SortOrder.Ascending ? true : false;

            switch (searchCriteria.SortBy)
            {
            case (int)Enums.CompanySortBy.Name:
                dbCompanies = isAsc ? dbCompanies.OrderBy(e => e.Name) : dbCompanies.OrderByDescending(e => e.Name);
                break;

            case (int)Enums.CompanySortBy.Nip:
                dbCompanies = isAsc ? dbCompanies.OrderBy(e => e.Nip) : dbCompanies.OrderByDescending(e => e.Nip);
                break;

            case (int)Enums.CompanySortBy.Regon:
                dbCompanies = isAsc ? dbCompanies.OrderBy(e => e.Regon) : dbCompanies.OrderByDescending(e => e.Regon);
                break;

            case (int)Enums.CompanySortBy.Symbol:
                dbCompanies = isAsc ? dbCompanies.OrderBy(e => e.Symbol) : dbCompanies.OrderByDescending(e => e.Symbol);
                break;

            default:
                break;
            }

            return(dbCompanies
                   .Skip(searchCriteria.PageIndex * searchCriteria.PageSize)
                   .Take(searchCriteria.PageSize));
        }
Exemple #18
0
        public async Task <List <CompanyResult> > GetCompaniesEmployeesAsync(CompanySearch model)
        {
            var predicate = GetCompaniesEmployeesFilter(model);

            return(await Context.Companies
                   .AsNoTracking()
                   .Include(i => i.Employees)
                   .Where(predicate)
                   .Select(s => new CompanyResult
            {
                Name = s.Name,
                FoundationYear = s.FoundationYear,
                Employees = s.Employees.Select(x => new CompanyEmployeeResult
                {
                    BirthDate = x.BirthDate,
                    FirstName = x.FirstName,
                    JobTitle = x.JobTitle,
                    LastName = x.LastName
                }).ToList()
            })
                   .ToListAsync());
        }
Exemple #19
0
        public async Task Get_Companies_Employees_With_Search()
        {
            //Arrange
            var searchModel = new CompanySearch
            {
                Keyword           = "jakub",
                EmployeeJobTitles = new List <JobTitle> {
                    JobTitle.Developer
                },
                EmployeeBirthDateFrom = new DateTime(1998, 01, 01),
                EmployeeBirthDateTo   = new DateTime(2000, 01, 01),
            };

            //Act
            var companyResult = await CompanyRepository.AddAsync(_newCompany);

            var companies = await CompanyRepository.GetCompaniesEmployeesAsync(searchModel);

            await CompanyRepository.DeleteAsync(companyResult.Id);

            //Assert
            Assert.IsTrue(companies.Count > 0);
        }
Exemple #20
0
        public override async Task <Tuple <List <Model.Response.Company>, int> > GetByParametersAsync(CompanySearch search, string order, string nameOfColumnOrder, int start, int length)
        {
            var query = ctx.Companies
                        .Include(x => x.City)
                        .AsQueryable();

            if (search.Active != null)
            {
                query = query.Where(x => x.Active == search.Active);
            }
            if (search.CityID != null)
            {
                query = query.Where(x => x.CityId == search.CityID);
            }
            if (search.CountryID != null)
            {
                query = query.Where(x => x.City.CountryID == search.CountryID);
            }
            if (!string.IsNullOrWhiteSpace(search.Address))
            {
                query = query.Where(x => x.Address.Contains(search.Address, StringComparison.CurrentCultureIgnoreCase));
            }
            if (!string.IsNullOrWhiteSpace(search.ContactAgent))
            {
                query = query.Where(x => x.ContactAgent.Contains(search.ContactAgent, StringComparison.CurrentCultureIgnoreCase));
            }
            if (!string.IsNullOrWhiteSpace(search.Name))
            {
                query = query.Where(x => x.Name.Contains(search.Name, StringComparison.CurrentCultureIgnoreCase));
            }

            if (nameof(Database.Company.ID) == nameOfColumnOrder)
            {
                query = query.OrderByAscDesc(x => x.ID, order);
            }
            else if (nameof(Database.Company.Name) == nameOfColumnOrder)
            {
                query = query.OrderByAscDesc(x => x.Name, order);
            }
            else if (nameof(Database.Company.ContactAgent) == nameOfColumnOrder)
            {
                query = query.OrderByAscDesc(x => x.ContactAgent, order);
            }
            else if (nameof(Database.Company.PhoneNumber) == nameOfColumnOrder)
            {
                query = query.OrderByAscDesc(x => x.PhoneNumber, order);
            }
            else if (nameof(Database.Company.CityId) == nameOfColumnOrder)
            {
                query = query.OrderByAscDesc(x => x.City.Name, order);
            }

            var data = mapper.Map <List <Model.Response.Company> >(await query.Skip(start).Take(length).ToListAsync());

            return(new Tuple <List <Model.Response.Company>, int>(data, await query.CountAsync()));
        }
Exemple #21
0
        public async Task <CustomResults <IEnumerable <CompanyDTO> > > Search(CompanySearch search)
        {
            var results = new CustomResults <IEnumerable <CompanyDTO> >();

            try
            {
                var companies = await _companyRepository.GetAll();

                if (companies.NotNullOrEmpty())
                {
                    var filteredCompanies = new List <Company>();

                    if (!string.IsNullOrEmpty(search.Keyword))
                    {
                        filteredCompanies = companies.Where(x =>
                                                            x.Employees != null && x.Employees.Any(e => e.Name == search.Keyword) ||
                                                            x.Employees != null && x.Employees.Any(e => e.Surname == search.Keyword) ||
                                                            x.Name == search.Keyword).ToList();
                    }

                    if (search.EmployeeDateOfBirthFrom != null)
                    {
                        filteredCompanies = companies.Where(x => x.Employees != null && x.Employees.Any(e => e.BirthDate > search.EmployeeDateOfBirthFrom)).ToList();
                    }

                    if (search.EmployeeDateOfBirthTo != null)
                    {
                        filteredCompanies = companies.Where(x => x.Employees != null && x.Employees.Any(e => e.BirthDate < search.EmployeeDateOfBirthTo)).ToList();
                    }

                    if (!string.IsNullOrEmpty(search.EmployeeJobTitle))
                    {
                        if (Enum.TryParse(search.EmployeeJobTitle, out JobTitle jobTitle))
                        {
                            filteredCompanies = companies.Where(x => x.Employees != null && x.Employees.Any(e => e.JobTitle == jobTitle)).ToList();
                        }
                        else
                        {
                            results.StatusCode = HttpStatusCode.BadRequest;
                            results.Message    = $"There's no such a job title like: {search.EmployeeJobTitle}";
                            return(results);
                        }
                    }

                    filteredCompanies = filteredCompanies.Distinct().ToList();
                    if (filteredCompanies.Count == 0)
                    {
                        results.StatusCode = HttpStatusCode.OK;
                        results.Message    = $"No companies are found under such criteria.";
                        return(results);
                    }

                    var mappedCompanies = _mapper.Map <List <CompanyDTO> >(filteredCompanies);
                    if (mappedCompanies != null)
                    {
                        results.StatusCode = HttpStatusCode.OK;
                        results.Message    = $"Found {filteredCompanies.Count} objects";
                        results.Result     = mappedCompanies;
                    }
                }
                else
                {
                    results.StatusCode = HttpStatusCode.InternalServerError;
                    results.Message    = Consts.DATABASE_FETCH_ERROR;
                }
            }
            catch (Exception ex)
            {
                results.StatusCode = HttpStatusCode.InternalServerError;
                results.Message    = ex.Message;
            }

            return(results);
        }
Exemple #22
0
 public async Task <IEnumerable <Company> > GetAsync(CompanySearch option, CancellationToken token = default(CancellationToken))
 => await companyQueryProcessor.GetAsync(option, token);
        public ActionResult CompanyDispatcher()
        {
            var companySearch = new CompanySearch();

            return(View("CompanyDispatcher", companySearch));
        }
Exemple #24
0
        public async Task <IActionResult> GetCompaniesAsync([FromBody] CompanySearch request)
        {
            var companies = await _companyRepository.GetCompaniesEmployeesAsync(request);

            return(Ok(companies));
        }
Exemple #25
0
 public async Task <ActionResult <IEnumerable <Company> > > GetItems(CompanySearch option, CancellationToken token)
 => (await companyProcessor.GetAsync(option, token)).ToArray();