Ejemplo n.º 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;
        }
    }
Ejemplo n.º 2
0
 void CallOut(Schedule sched, OpenShift shift)
 {
     if (CalledOut != null)
     {
         CalledOut(sched, shift);
     }
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 4
0
 public void OpenShift(OpenShift shift)
 {
     if (ShiftOpened != null)
     {
         if (!OpenShifts.Contains(shift))
         {
             OpenShifts.Add(shift);
             HasOpenShifts = true;
             ShiftOpened(shift);
         }
     }
 }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 8
0
 void HandleOnShiftOpened(OpenShift shift)
 {
     Debug.Log(shift.RequiredTitle + " " + shift.Shift + "shift on " + shift.Day + " was opened!");
 }
Ejemplo n.º 9
0
 void HandleOnShiftCovered(Employee emp, OpenShift shift)
 {
     Debug.Log("Scheduled shift for " + shift.RequiredTitle + " " + shift.Day + " " + shift.Shift + " was covered by " + emp.Name + "!");
 }
Ejemplo n.º 10
0
 void HandleOnCovered(OpenShift shift)
 {
     Debug.Log(Employee.Name + " covered " + shift.Day + " " + shift.Shift + " as a " + shift.RequiredTitle);
 }
Ejemplo n.º 11
0
 public OpenShiftTests() : base()
 {
     oc = new OpenShift(null, Api.Ct);
 }