Example #1
0
    public void Randomize(Title title)
    {
        var rand = new System.Random();
        int numberOfOpenShifts = rand.Next(5, 10); //create a random number between 5 and 20. this decides how many openshifts to give the employee

        Title      = title;
        Id         = Guid.NewGuid();
        Gender     = (Gender)rand.Next(0, 2);
        OpenShifts = new List <OpenShift>();

        for (var i = 0; numberOfOpenShifts >= OpenShifts.Count;)
        {
            var randomShift = new OpenShift {
                Day = (DayOfWeek)rand.Next(0, 8), Shift = (Shift)rand.Next(0, 3), RequiredTitle = Title
            };
            if (!OpenShifts.Contains(randomShift))
            {
                OpenShifts.Add(randomShift);
                ++i;
            }
        }


        if (Gender == Gender.Male)
        {
            Name = RandomName.MaleName;
        }
        if (Gender == Gender.Female)
        {
            Name = RandomName.FemaleName;
        }
    }
Example #2
0
 void CallOut(Schedule sched, OpenShift shift)
 {
     if (CalledOut != null)
     {
         CalledOut(sched, shift);
     }
 }
Example #3
0
 void HandleOnCalledOut(Schedule sched, OpenShift shift)
 {
     if (!Employee.OpenShifts.Contains(shift)) //make sure the employee is working this shift
     {
         Employee.OpenShifts.Add(shift);
         sched.OpenShift(shift);
         Employee.HasOpenShifts = true;
     }
 }
Example #4
0
 public void OpenShift(OpenShift shift)
 {
     if (ShiftOpened != null)
     {
         if (!OpenShifts.Contains(shift))
         {
             OpenShifts.Add(shift);
             HasOpenShifts = true;
             ShiftOpened(shift);
         }
     }
 }
Example #5
0
 public void Cover(OpenShift shift)
 {
     if (Covered != null)
     {
         if (OpenShifts.Contains(shift))
         {
             OpenShifts.Remove(shift);
             if (!WorkShifts.Contains(shift))
             {
                 WorkShifts.Add(shift);
             }
             Covered(shift);
         }
     }
 }
Example #6
0
 public void CoverShift(Employee emp, OpenShift shift)
 {
     if (ShiftCovered != null)
     {
         if (OpenShifts.Contains(shift) && emp.OpenShifts.Contains(shift)) //schedule has an openshift on this date, so does employee
         {
             emp.Cover(shift);
             OpenShifts.Remove(shift);
             if (OpenShifts.Count == 0)
             {
                 HasOpenShifts = false;
             }
             ShiftCovered(emp, shift);
         }
     }
 }
        /// <summary>
        /// Create new navigation property to openShifts for users
        /// <param name="body"></param>
        /// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
        /// </summary>
        public RequestInformation CreatePostRequestInformation(OpenShift body, Action <OpenShiftsRequestBuilderPostRequestConfiguration> requestConfiguration = default)
        {
            _ = body ?? throw new ArgumentNullException(nameof(body));
            var requestInfo = new RequestInformation {
                HttpMethod     = Method.POST,
                UrlTemplate    = UrlTemplate,
                PathParameters = PathParameters,
            };

            requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body);
            if (requestConfiguration != null)
            {
                var requestConfig = new OpenShiftsRequestBuilderPostRequestConfiguration();
                requestConfiguration.Invoke(requestConfig);
                requestInfo.AddRequestOptions(requestConfig.Options);
                requestInfo.AddHeaders(requestConfig.Headers);
            }
            return(requestInfo);
        }
Example #8
0
 void HandleOnShiftOpened(OpenShift shift)
 {
     Debug.Log(shift.RequiredTitle + " " + shift.Shift + "shift on " + shift.Day + " was opened!");
 }
Example #9
0
 void HandleOnShiftCovered(Employee emp, OpenShift shift)
 {
     Debug.Log("Scheduled shift for " + shift.RequiredTitle + " " + shift.Day + " " + shift.Shift + " was covered by " + emp.Name + "!");
 }
Example #10
0
 void HandleOnCovered(OpenShift shift)
 {
     Debug.Log(Employee.Name + " covered " + shift.Day + " " + shift.Shift + " as a " + shift.RequiredTitle);
 }
Example #11
0
 public OpenShiftTests() : base()
 {
     oc = new OpenShift(null, Api.Ct);
 }