﻿using DertInfo.WEB.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace DertInfo.WEB.ViewModels.MemberAttendanceVMs
{
    public class MemberAttendanceSignUpViewModel : MemberAttendanceVMs.MemberAttendanceViewModel
    {
        

        //Constructors
        public MemberAttendanceSignUpViewModel(Models.MemberAttendance memberAttendance)
            : base(memberAttendance)
        {
            //this.SelectableGroupMemberVMs = new List<GroupMemberVMs.GroupMemberViewModel_Selectable>();

            this.ToView(memberAttendance);
        }

        //Properties
        //public List<GroupMemberVMs.GroupMemberViewModel_Selectable> SelectableGroupMemberVMs { get; set; }
        public IEnumerable<SelectListItem> AttendanceClassificationSL { get; set; }

        //Methods
        //public List<GroupMemberVMs.GroupMemberViewModel_Selectable> GetSelectedGroupMembers()
        //{
        //    //return SelectableGroupMemberVMs.Where(c => c.IsSelected).ToList();
        //}

        internal void ToView(Models.MemberAttendance memberAttendance)
        {
            base.ToView(memberAttendance);

            FillAttendanceClassification();

            
        }

        private void FillAttendanceClassification()
        {
            IAttendanceClassificationRepository attendanceClassificationRepo = new AttendanceClassificationRepository();
            IRegistrationRepository registrationRepo = new RegistrationRepository();

            Registration registration = registrationRepo.Find(base.GroupRegistrationId);


            List<AttendanceClassification> attendanceClassifications = attendanceClassificationRepo.AllByEventId(registration.EventId).ToList();

            this.AttendanceClassificationSL = from ac in attendanceClassifications
                                              select new SelectListItem
                                              {
                                                  Text = ac.ClassificationName,
                                                  Value = ac.Id.ToString()
                                              };


        }

        //private void FillGroupMembers()
        //{
        //    IGroupMemberRepository groupMemberRepo = new GroupMemberRepository();
        //    List<Models.GroupMember> groupMembers = groupMemberRepo.AllByGroupId(base.GroupMemberVM.GroupId).ToList();
        //}
    }
}
