コード例 #1
0
        public static List<EmployeeModel> GetAllEmployees()
        {
            List<EmployeeModel> employeeModelList=new List<EmployeeModel>();
            FileSystem file = new FileSystem();
            List<string> empId = file.RetrieveAllIds();
            for (int i = 0; i < empId.Count - 1; i++)
            {
                employeeModelList.Add(GetEmployeeById(empId[i]));

            }
            return employeeModelList;
        }
コード例 #2
0
        /*
                        Dictionary<string, string> employeeDictionary = new Dictionary<string, string>();
                        employeeDictionary.Add("Id",this.Id);
                        employeeDictionary.Add("Title",this.Title);
                        employeeDictionary.Add("FistName",this.FirstName);
                        employeeDictionary.Add("LastName",this.LastName);
             * string str = "{\"Arg1\":\"Arg1Value\",\"Arg2\":\"Arg2Value\"}";
            JavaScriptSerializer serializer1 = new JavaScriptSerializer();
            object obje = serializer1.Deserialize(str, obj1.GetType());
                        employeeDictionary.Add("Email",this.Email);ng
                        var save = new FileSystem();
                        save.SaveEmployee(employeeDictionary);
             * */
        public static EmployeeModel GetEmployeeById(string id)
        {
            FileSystem file = new FileSystem();

            EmployeeModel employeeModel = JsonConvert.DeserializeObject<EmployeeModel>(file.RetrieveById(id));

            return employeeModel;
        }
コード例 #3
0
        public static void InsertEmployeeIntoFile(EmployeeModel employee)
        {
            var jsonString = JsonConvert.SerializeObject(employee);

            FileSystem file = new FileSystem();
            file.SaveEmployee(jsonString, employee.Id);
        }