示例#1
0
        public ActionResult SearchOrganisation()
        {
            ViewBag.ScreenName        = "Organisation";
            ViewBag.ScreenDescription = "search";

            EvolutionRepository.Models.User user = new EvolutionRepository.Models.User();
            //Get Current User
            ViewBag.User = user;

            return(View());
        }
        //[AuthorizeWebAPI()]
        public EvolutionRepository.ManualModels.SearchResult Get([FromUri] EvolutionRepository.ManualModels.SearchOrganisationsParams searchParams)
        {
            //EvolutionRepository.Models.User LoggedInUser = (EvolutionRepository.Models.User)System.Web.HttpContext.Current.Session["UserInfo"];
            //if (LoggedInUser == null)
            //{
            //    throw new EvolutionBusinessLogic.Exceptions.EvolutionException("Not Authenticated!");
            //}

            EvolutionRepository.Models.User LoggedInUser = new EvolutionRepository.Models.User();
            var result = EvolutionBusinessLogic.Search.SearchOrganisations.SearchForOrganisations(searchParams, LoggedInUser);

            return(result);
        }
示例#3
0
        public static List <EvolutionRepository.ManualModels.EmployeeGrid> GetEmployees(EvolutionRepository.ManualModels.SearchEmployeeParams searchParams, EvolutionRepository.Models.User LoggedInUser, out int TotalInstancesWithoutSkipTake)
        {
            List <EvolutionRepository.ManualModels.EmployeeGrid> Employees = new List <EvolutionRepository.ManualModels.EmployeeGrid>();

            using (EvolutionRepository.Models.EvolutionDBContext ctx = new EvolutionRepository.Models.EvolutionDBContext())
            {
                try
                {
                    Employees = ctx.Database.SqlQuery <EvolutionRepository.ManualModels.EmployeeGrid>(
                        "Ev_EmployeeSearch @FirstName, @EmployeeTypeID",
                        new SqlParameter("@FirstName", searchParams.FirstName),
                        new SqlParameter("@EmployeeTypeID", searchParams.EmployeeTypeID))
                                .ToList();

                    TotalInstancesWithoutSkipTake = Employees.Count;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            return(Employees.OrderBy(x => x.EmployeeID).Skip(searchParams.skip).Take(searchParams.take).ToList());
        }
        public static EvolutionRepository.ManualModels.SearchResult SearchForOrganisations(EvolutionRepository.ManualModels.SearchOrganisationsParams searchParams, EvolutionRepository.Models.User LoggedInUser)
        {
            var organisationsFound = new List <EvolutionRepository.ManualModels.OrganisationGrid>();

            try
            {
                //Call DAL and return organisation that the user is allowesd to within the search params
                var FoundOrganisations = EvolutionDataAccess.Search.SearchDAL.GetOrganisations(searchParams, LoggedInUser, out TotalInstancesWithoutSkipTake);

                foreach (var foundOrganisation in FoundOrganisations)
                {
                    var newOrganisation = new EvolutionRepository.ManualModels.OrganisationGrid()
                    {
                        OrganisationID   = foundOrganisation.OrganisationID,
                        OrganisationName = foundOrganisation.OrganisationName,
                        DateAdded        = foundOrganisation.DateAdded,
                        DateDeleted      = foundOrganisation.DateDeleted,
                    };

                    if (foundOrganisation.CompanyNumber != null)
                    {
                        newOrganisation.CompanyNumber = foundOrganisation.CompanyNumber;
                    }
                    if (foundOrganisation.TelephoneNo != null)
                    {
                        newOrganisation.TelephoneNo = foundOrganisation.TelephoneNo;
                    }
                    if (foundOrganisation.ContactName != null)
                    {
                        newOrganisation.ContactName = foundOrganisation.ContactName;
                    }
                    if (foundOrganisation.WebSiteURL != null)
                    {
                        newOrganisation.WebSiteURL = foundOrganisation.WebSiteURL;
                    }
                    if (foundOrganisation.OrganisationStatusName != null)
                    {
                        newOrganisation.OrganisationStatusName = foundOrganisation.OrganisationStatusName;
                    }

                    organisationsFound.Add(newOrganisation);
                }
            }
            catch (Exception ex)
            {
                throw new EvolutionBusinessLogic.Exceptions.EvolutionException("Database error", "Evolution could not process the required stored procedure succesully. " + ex.Message);
            }

            return(new EvolutionRepository.ManualModels.SearchResult(organisationsFound.ToArray(), TotalInstancesWithoutSkipTake));
        }