public ActionResult ListPracticeAttendance() { var Users = Session["Users"] as Users; List <PracticeAttended> practice = attendance.getPracticeAttendaned(Users.TeamID); return(View(practice)); }
public static CountAttendance GetPracticeAttendanceUser(int teamid, int userid) { //create count attendance variable CountAttendance count = new CountAttendance(); //get the users full name count.FullName = usersBLL.GetUsers().Find(m => m.UserID == userid).FullName; //get the total attendance for the team List <PracticeAttended> getAttendance = attendance.getPracticeAttendaned(teamid); //store in a list the total times the user has been present List <PracticeAttended> userPresent = getAttendance.FindAll(m => m.UserID == userid).FindAll(m => m.Attended == true); //store in a list the total times the user has been absent List <PracticeAttended> userAbsent = getAttendance.FindAll(m => m.UserID == userid).FindAll(m => m.Attended == false); //make another list to get the total number of times attendance has been tracked for the user List <PracticeAttended> total = new List <PracticeAttended>(); //add both present and absent list to total total.AddRange(userPresent); total.AddRange(userAbsent); //count the number of absences and store in count count.NumAbsent = userAbsent.Count; //count the number of present count.NumPresent = userPresent.Count; //count the total number of times attendance has been tracked count.total = total.Count; //get a ratio of percentage absent if (count.total == 0) { count.AbsentRatio = 0; //get a percentage ratio of present count.PresentRatio = 0; //return attendance count for statistics } else { count.AbsentRatio = count.NumAbsent / count.total; //get a percentage ratio of present count.PresentRatio = count.NumAbsent / count.total; //return attendance count for statistics } return(count); }
public ActionResult TwoLevelPractice(PracticeModel practice) { if (ModelState.IsValid) { if (practice.PracticeType == "") { ViewBag.Message = "Cannot leave practice blank"; return(View(practice)); } if (practice.StartTime < DateTime.Now) { ViewBag.Message = "Start Time cannot be earlier than todays date"; return(View(practice)); } else if (practice.EndTime < DateTime.Now) { ViewBag.Message = "End Time Cannot be earlier than todays date"; return(View(practice)); } else if (practice.StartTime > practice.EndTime) { ViewBag.Message = "Start Time Cannot be later than End Time"; return(View(practice)); } else if (practice.StartTime == DateTime.MinValue || practice.EndTime == DateTime.MinValue) { ViewBag.Message = "Cannot be the beggining of time"; return(View(practice)); } var users = Session["Users"] as Users; Practice createPractice = new Practice(); PracticeAttended absent = new PracticeAttended(); createPractice.PracticeType = practice.PracticeType; createPractice.StartTime = practice.StartTime; createPractice.EndTime = practice.EndTime; absent.UserID = practice.UserID; absent.Attended = practice.Check; createPractice.TeamID = users.TeamID; practiceBLL.CreatePractice(createPractice); List <Practice> check = practiceBLL.GetPractice(); check.Reverse(); Practice checkinsert = check.Find(m => m.PracticeType == createPractice.PracticeType && m.StartTime == createPractice.StartTime && m.EndTime == createPractice.EndTime); absent.PracticeID = checkinsert.PracticeID; attendance.CreatePracticeAttendance(absent); bool insert = check.Exists(m => m.PracticeType == practice.PracticeType); bool checkInsert = attendance.getPracticeAttendaned(users.TeamID).Exists(m => m.PracticeID == check[0].PracticeID); if (insert && checkInsert) { ViewBag.Message = "Practice and Attendance Created"; } else if (insert && checkInsert == false) { ViewBag.Message = "Only Practice Added"; } else if (insert == false && checkInsert == false) { ViewBag.Message = "No Insert Made"; } else { } } else { ViewBag.Message = "Invalid Entry"; } return(View(practice)); }