/// <summary> /// It create Employee Object /// If Employee Already Exist in the list, then it will throw FaultException /// </summary> /// <param name="id">Employee Id</param> /// <param name="name">Employee Name</param> /// <param name="comment">Employee Comment</param> /// <returns>Employee Object</returns> public EmployeeManagement CreateEmployee(int id, string name, string comment) { EmployeeManagement employeeObj = new EmployeeManagement(); EmployeeServiceFault fault = new EmployeeServiceFault(); if (_employeelist.Any(e => e.EmployeeID == id)) { fault.FaultId = 101; fault.FaultMessage = "Employee Already Exists"; fault.FaultDetail = "Employee Already Present in the List"; throw new FaultException <EmployeeServiceFault>(fault, "Employee Already Exists"); } else { employeeObj.EmployeeID = id; employeeObj.EmployeeName = name; employeeObj.Comment = comment; employeeObj.TimeSubmitted = DateTime.Now; return(employeeObj); } }
/// <summary> /// It Add Employee Object in List /// </summary> /// <param name="emp">Employee Object</param> public void AddEmployee(EmployeeManagement emp) { _employeelist.Add(emp); }