Advertisement
Odense

Record

Mar 3rd, 2021
874
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. class Program
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.             String RecordType = "Vacancy";
  6.  
  7.             Record softwareEngineerVacancy = new Record("SoftwareEngineer0001", RecordType);
  8.             Record frontEndEngineerVacancy = new Record("FrontEndEngineer0020", RecordType);
  9.  
  10.             NotifyManager.Notify += DisplayMessage;
  11.             NotifyManager.SubmitForApproval(softwareEngineerVacancy.Id);
  12.             NotifyManager.Approve(softwareEngineerVacancy.Id);
  13.             NotifyManager.SubmitForApproval(frontEndEngineerVacancy.Id);
  14.             NotifyManager.Reject(frontEndEngineerVacancy.Id);
  15.         }
  16.  
  17.         private static void DisplayMessage(string message)
  18.         {
  19.             Console.WriteLine(message);
  20.         }
  21.  
  22.         public class NotifyManager {
  23.             public delegate void NotifyManagerHandler(string message);
  24.             public static event NotifyManagerHandler Notify;
  25.  
  26.             public static void SubmitForApproval(string id)
  27.             {
  28.                 Notify?.Invoke($"Submitted for approval Vacancy: {id}");
  29.             }
  30.  
  31.             public static void Approve(string id)
  32.             {
  33.                 Notify?.Invoke($"Approved Record: {id}");
  34.             }
  35.  
  36.             public static void Reject(string id)
  37.             {
  38.                 Notify?.Invoke($"Reject Record: {id}");
  39.             }
  40.  
  41.         }
  42.  
  43.         public class Record
  44.         {
  45.             public String Id { get; private set; }
  46.             public String Type { get; private set; }
  47.  
  48.             public Record(String Id, String Type)
  49.             {
  50.                 this.Id = Id;
  51.                 this.Type = Type;
  52.             }
  53.         }
  54.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement