示例#1
0
 public static List <StudentInSubscriptionDTO> GetStudentInSubscriptionListByStudentId(int studentId)
 {
     using (Gymnastics_Studio_DataEntities GSDE = new Gymnastics_Studio_DataEntities())
     {
         List <List <StudentInSubscriptionDTO> > studentInSubscriptionListsList = new List <List <StudentInSubscriptionDTO> >();
         List <StudentInSubscription>            studentInSubscriptionList      = new List <StudentInSubscription>();
         List <Payment> paymentList = PaymentDTO.ConvertListFromDTO(PaymentFunction.GetStudentPaymentsList(studentId));
         foreach (Payment payment in paymentList)
         {
             studentInSubscriptionList = GSDE.StudentInSubscriptions.Where(x => x.StudentId == studentId && x.StartDate < payment.StartDate).ToList();
             studentInSubscriptionListsList.Add(StudentInSubscriptionDTO.ConvertListToDTO(studentInSubscriptionList));
         }
         return(StudentInSubscriptionDTO.ConvertListToDTO(studentInSubscriptionList));
     }
 }
示例#2
0
        public static List <List <string> > GetStudentInSubscriptionNamesListByStudentId(int studentId)
        {
            using (Gymnastics_Studio_DataEntities GSDE = new Gymnastics_Studio_DataEntities())
            {
                List <List <StudentInSubscriptionDTO> > studentInSubscriptionListsList = new List <List <StudentInSubscriptionDTO> >();
                List <StudentInSubscription>            studentInSubscriptionList      = new List <StudentInSubscription>();
                List <List <string> > subscriptionNameList = new List <List <string> >();
                List <Payment>        paymentList          = PaymentDTO.ConvertListFromDTO(PaymentFunction.GetStudentPaymentsList(studentId));
                int i = -1;
                foreach (Payment payment in paymentList)
                {
                    i++;
                    studentInSubscriptionList = GSDE.StudentInSubscriptions.Where(x => x.StudentId == studentId && (x.StartDate > payment.StartDate && x.StartDate < payment.FinishDate || x.FinishDate <payment.FinishDate && x.FinishDate> payment.StartDate)).ToList();
                    for (int j = 0; j < studentInSubscriptionList.Count(); j++)

                    {
                        subscriptionNameList[i].Add(GSDE.Subscriptions.FirstOrDefault(x => x.Id == studentInSubscriptionList[j].Id).Name);
                    }
                    studentInSubscriptionListsList.Add(StudentInSubscriptionDTO.ConvertListToDTO(studentInSubscriptionList));
                }
                return(subscriptionNameList);
            }
        }