Exemplo n.º 1
0
 public void MakePair(MemberBooking model, out bool isSuccess)
 {
     if (model != null)
     {
         TimeSpan              machTime = model.StartDate.TimeOfDay;
         DayOfWeek             machWeek = model.StartDate.DayOfWeek;
         MemberBookingAssigner assigner = model.Assigners.LastOrDefault();
         if (_CheckAssignStatus(assigner))
         {
             isSuccess = true;
             return;
         }
         foreach (MemberWorkTime teacher in Model.Teachers)
         {
             MemberWorkTimeItem item = teacher.Times.FirstOrDefault(x => x.Time == machTime && x.Weekday == machWeek);
             if (item != null)
             {
                 if (item.Exceptions.Count > 0)
                 {
                     if (item.Exceptions.LastOrDefault().Status == Status.Disabled)
                     {
                         continue;
                     }
                 }
                 model.Assigners.Add(new MemberBookingAssigner()
                 {
                     Id              = PublicMethod.GetToken(),
                     MemberId        = item.MemberId,
                     MemberBookingId = model.Id,
                     Role            = AssignerRole.Teacher,
                     Status          = AssignStatus.Assigned
                 });
                 model.Status = BookingStatus.Confirm;
                 _removeStock(item);
                 break;
             }
         }
         assigner = model.Assigners.LastOrDefault();
         if (_CheckAssignStatus(assigner))
         {
             isSuccess = true;
         }
         else
         {
             isSuccess = false;
         }
     }
     else
     {
         isSuccess = false;
     }
 }
Exemplo n.º 2
0
 private bool _CheckAssignStatus(MemberBookingAssigner assign)
 {
     if (assign == null)
     {
         return(false);
     }
     if (assign.Status == AssignStatus.Assigned)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }