protected void rptSearch_ItemDataBound(object sender, RepeaterItemEventArgs e) // NOSONAR
        {
            var item = e.Item;

            if (item.ItemType != ListItemType.AlternatingItem && item.ItemType != ListItemType.Item)
            {
                return;
            }

            var person = (Person)e.Item.DataItem;

            bool inFavouritesList = StaticCache.IsPersonInFavourites(person);
            var  lnkFavourite     = (HyperLink)item.FindControl("lnkFavouritesIndicator");

            lnkFavourite.NavigateUrl = String.Format("Javascript:UpdateFavourites({0})", person.EmployeeNumber);
            if (inFavouritesList)
            {
                lnkFavourite.CssClass = "fa fa-star";
            }

            var lblGender = (Label)item.FindControl("lblGender");

            lblGender.Text = Enums.StringValueOf(person.Gender);

            var furtherInfoLink = (HyperLink)item.FindControl("lnkFurtherInfo");

            furtherInfoLink.NavigateUrl = String.Format("Javascript:FurtherInfo({0})", person.EmployeeNumber);
        }
Beispiel #2
0
        public static Person FindPersonById(string Id)
        {
            List <Person> employees = StaticCache.GetEmployees();

            //Person foundPerson = (Person)employees.FirstOrDefault(a => a.EmployeeNumber.Equals(Id));
            return(employees.Find(a => a.EmployeeNumber.Equals(Id)));
        }
        public static List <Person> GetFilteredData(string firstName, string lastName, string office, string department, bool active)
        {
            IQueryable <Person> oDataQuery = StaticCache.GetEmployees().AsQueryable();

            if (firstName.Trim().Length > 0)
            {
                oDataQuery = oDataQuery.Where(a => a.FirstName.StartsWith(firstName, true, CultureInfo.InvariantCulture));
            }

            if (lastName.Trim().Length > 0)
            {
                oDataQuery = oDataQuery.Where(a => a.LastName.StartsWith(lastName, true, CultureInfo.InvariantCulture));
            }

            if (office.Trim().Length > 0)
            {
                oDataQuery = oDataQuery.Where(a => a.Office.Id.ToString().Equals(office.ToString()));
            }

            if (department.Trim().Length > 0)
            {
                oDataQuery = oDataQuery.Where(a => a.Department.Id.ToString().Equals(department.ToString()));
            }

            return(oDataQuery.ToList());
        }
Beispiel #4
0
        private void LoadData()
        {
            var favouritesList = StaticCache.GetFavourites();

            rptFavourites.DataSource = favouritesList;
            rptFavourites.DataBind();

            if (favouritesList.Count > 0)
            {
                noneSelected.Visible = false;
            }
        }
 public static object GetPersonById(string id)
 {
     try
     {
         List <Person> employees = StaticCache.GetEmployees();
         var           filtered  = employees.Where(x => x.EmployeeNumber.ToString() == id).ToList();
         return(JsonConvert.SerializeObject(filtered, Formatting.Indented));
     }
     catch (Exception exception)
     {
         throw new Exception(string.Format("Error Loading Instance with id {0}, Error: {1}", id, exception));
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            // Retrieve request parameters
            var id = Request.QueryString["id"];

            // Check for null parameters, and if found, return BadRequest statusCode
            if (string.IsNullOrEmpty(id))
            {
                Response.StatusCode = BadRequest;
                return;
            }

            // Lookup person by employeeNumber
            Person person = StaticCache.FindPersonById(id);

            StaticCache.PersonToFavourites(person);
        }
        private void LoadDpartments()
        {
            lstDepartments.Items.Clear();
            lstDepartments.Items.Add(new ListItem("All Departments", ""));

            var departments = StaticCache.GetDepartments();

            foreach (var department in departments)
            {
                lstDepartments.Items.Add(new ListItem(department.Name, department.Id.ToString(CultureInfo.InvariantCulture)));
            }

            // select previous value
            if (!string.IsNullOrEmpty(_departmentId))
            {
                lstDepartments.SelectedIndex = lstDepartments.Items.IndexOf(lstDepartments.Items.FindByValue(_departmentId));
            }
        }
        private void LoadOffices()
        {
            lstOffices.Items.Clear();
            lstOffices.Items.Add(new ListItem("All Offices", ""));

            var offices = StaticCache.GetOffices();

            foreach (var office in offices)
            {
                lstOffices.Items.Add(new ListItem(office.Name, office.Id.ToString(CultureInfo.InvariantCulture)));
            }

            // select previous value
            if (!string.IsNullOrEmpty(_officeId))
            {
                lstOffices.SelectedIndex = lstOffices.Items.IndexOf(lstOffices.Items.FindByValue(_officeId));
            }
        }
Beispiel #9
0
 private void SetFavouritesCount()
 {
     lblFavouritesCount.InnerText = StaticCache.GetFavourites().Count.ToString();
 }
Beispiel #10
0
        public static bool IsPersonInFavourites(Person person)
        {
            List <Person> favourites = StaticCache.GetFavourites();

            return(favourites.Exists(a => a.EmployeeNumber.Equals(person.EmployeeNumber)));
        }
Beispiel #11
0
 void Application_Start(object sender, EventArgs e)
 {
     // Code that runs on application startup
     StaticCache.LoadStaticCache();
 }