private void MergeIntoAllCollection(EmployeeRM employee)
        {
            List <EmployeeRM> allEmployees = new List <EmployeeRM>();

            if (Exists("all"))
            {
                allEmployees = Get <List <EmployeeRM> >("all");
            }

            // If the ?district already exists in the "all" collection, remove that entry

            if (allEmployees.Any(e => e.EmployeeID == employee.EmployeeID))
            {
                allEmployees.Remove(allEmployees.First(e => e.EmployeeID == employee.EmployeeID));
            }

            // Add the modified ?district to the "all" collection
            allEmployees.Add(employee);

            Save("all", allEmployees);
        }
 public void Save(EmployeeRM employee)
 {
     Save(employee.EmployeeID, employee);
     MergeIntoAllCollection(employee);
 }
Example #3
0
        public void Handle(EmployeeCreatedEvent message)
        {
            EmployeeRM employee = mapper.Map <EmployeeRM>(message);

            employeeRepo.Save(employee);
        }