public ActionResult SignatureList(int eventTypeID, string searchContent) { DateTime now = DateTime.Now.ToUniversalTime().AddHours(8); DateTime nowMore = now.AddHours(1.5); List <Event> currentEvents = (from r in _entities.Events where r.EventTypeID == eventTypeID && nowMore >= r.StartDateTime && now <= r.StartDateTime select r).ToList(); List <Event> allEventList = new List <Event>(); List <List <MemberInfoShortListViewModel> > allSginatureList = new List <List <MemberInfoShortListViewModel> >(); foreach (Event aEvent in currentEvents) { List <MemberInfoShortListViewModel> signatureList = new List <MemberInfoShortListViewModel>(); if (aEvent.EventTypeID == 3) // GM convienent method GM { signatureList = (from r in _entities.MemberInfos where r.InitiateTypeID == 3 && (r.Name.Contains(searchContent) || searchContent == null) orderby r.Name select new MemberInfoShortListViewModel() { ID = r.MemberID, Name = r.Name, }).ToList(); } else { var eventRegistrations = from r in _entities.EventRegistrations where r.EventID == aEvent.ID && (r.MemberInfo.Name.Contains(searchContent) || searchContent == null) orderby r.MemberInfo.Name select r; foreach (EventRegistration eventRegistation in eventRegistrations) { List <string> mValues1 = new List <string>(); MemberInfoShortListViewModel misvm = new MemberInfoShortListViewModel(); misvm.ID = eventRegistation.MemberID; misvm.Name = eventRegistation.MemberInfo.Name; signatureList.Add(misvm); } } allEventList.Add(aEvent); List <MemberInfoShortListViewModel> signatureListNoSign = new List <MemberInfoShortListViewModel>(); foreach (var item in signatureList) { var eventSignatures = from r in _entities.EventRegistrations where r.EventID == aEvent.ID && r.MemberID == item.ID && r.SignTime != null select r; if (eventSignatures.Count() == 0) { signatureListNoSign.Add(item); } } allSginatureList.Add(signatureListNoSign); } ViewData["EventTypeID"] = allEventList; return(View(allSginatureList)); }
public ActionResult SignatureList4GMAndLocalRetreat(int?page, string searchContent, int eventTypeID, int?eventID) { var currentPage = page ?? 1; ViewData["PageSize"] = _pageSize; ViewData["searchContent"] = searchContent; ViewData["EventTypeID"] = eventTypeID; int memberNO = 0; if (!string.IsNullOrEmpty(searchContent) && IsInteger(searchContent)) { memberNO = int.Parse(searchContent); } DateTime now = DateTime.Now.ToUniversalTime().AddHours(8); Event currentEvent; if (eventID == null) { DateTime registerBeginTime = now.AddHours(1.5); currentEvent = (from r in _entities.Events where r.EventTypeID == eventTypeID && registerBeginTime >= r.StartDateTime && now <= r.StartDateTime select r).FirstOrDefault(); } else { currentEvent = _entities.Events.Single(a => a.ID == eventID); } ViewData["Now"] = String.Format("{0:ddd, d MMM yyyy HH:mm }", now); List <MemberInfoShortListViewModel> signatureList = new List <MemberInfoShortListViewModel>(); if (currentEvent != null) { if (currentEvent.EventTypeID == 1) { var eventRegistrations = from r in _entities.EventRegistrations where r.EventID == currentEvent.ID && (r.MemberInfo.Name.Contains(searchContent) || searchContent == null || r.MemberInfo.MemberNo == memberNO) //orderby r.MemberInfo.InitiateMemberInfo.MemberTypeID, r.MemberInfo.InitiateMemberInfo.MemberNo orderby r.MemberInfo.Name select r; foreach (EventRegistration eventRegistation in eventRegistrations) { List <string> mValues1 = new List <string>(); //decimal personNeedToPay = (decimal)((from r in _entities.EventActivities where r.EventID == eventRegistation.EventID && r.Name.StartsWith("Bless") select r.UnitPrice).FirstOrDefault()); decimal personNeedToPay = _entities.EventPrices.Single(a => a.EventID == eventRegistation.EventID && a.EventActivityID == 8).UnitPrice; List <int> tValues = (from r in _entities.EventMealBookings where r.EventRegistrationID == eventRegistation.ID select r.EventScheduleID).ToList(); foreach (int localRetreatScheduleID in tValues) { int localRetreatActivityID = _entities.EventSchedules.Single(a => a.ID == localRetreatScheduleID).EventActivityID; personNeedToPay += (decimal)_entities.EventPrices.Single(a => a.EventActivityID == localRetreatActivityID && a.EventID == eventID).UnitPrice; } MemberInfoShortListViewModel misvm = new MemberInfoShortListViewModel(); misvm.ID = eventRegistation.MemberID; misvm.Name = eventRegistation.MemberInfo.Name; misvm.IDCardNo = eventRegistation.MemberInfo.IDCardNo; //misvm.ICOrPassportNo = eventRegistation.MemberInfo.InitiateMemberInfo.ICOrPassportNo; misvm.Money = personNeedToPay; //misvm.MemberType = eventRegistation.MemberInfo.InitiateMemberInfo.MemberType.Name; misvm.MemberNo = eventRegistation.MemberInfo.MemberNo; //misvm.MemberFeeExpiredDate = eventRegistation.MemberInfo.InitiateMemberInfo.MemberFeeExpiredDate; signatureList.Add(misvm); } ViewData["Title"] = currentEvent.Title + currentEvent.EventType.Name; } else if (currentEvent.EventTypeID == 2) //GM { signatureList = (from r in _entities.MemberInfos where (r.InitiateTypeID == 1 || r.InitiateTypeID == 2) && r.IsActive && (r.Name.Contains(searchContent) || searchContent == null || r.MemberNo == memberNO) //orderby r.InitiateMemberInfo.MemberTypeID, r.InitiateMemberInfo.MemberNo orderby r.MemberNo select new MemberInfoShortListViewModel() { ID = r.MemberID, Name = r.Name, IDCardNo = r.IDCardNo, //ICOrPassportNo = r.InitiateMemberInfo.ICOrPassportNo, //MemberType = r.InitiateMemberInfo.MemberType.Name, MemberNo = r.MemberNo, //MemberFeeExpiredDate = r.InitiateMemberInfo.MemberFeeExpiredDate, }).ToList(); ViewData["Title"] = String.Format("{0:ddd, d MMM yyyy }", currentEvent.StartDateTime) + String.Format("{0:HH:mm}", currentEvent.StartDateTime) + " to " + String.Format("{0:HH:mm}", currentEvent.EndDateTime) + ' ' + currentEvent.EventType.Name; } ViewData["eventSigedMemberIDs"] = (from r in _entities.EventRegistrations where r.EventID == currentEvent.ID && r.SignTime != null select r.MemberID).ToList(); //List<MemberInfoShortListViewModel> signatureListNoSign = new List<MemberInfoShortListViewModel>(); //foreach (var item in signatureList) //{ // var eventSignatures = from r in _entities.EventRegistrations where r.EventID == currentEvent.ID && r.MemberID == item.ID && r.SignTime != null select r; // if (eventSignatures.Count() == 0) // { // signatureListNoSign.Add(item); // } //} //ViewData["TotalPages"] = (int)Math.Ceiling((float)signatureListNoSign.Count() / _pageSize); ViewData["TotalPages"] = (int)Math.Ceiling((float)signatureList.Count() / _pageSize); if ((int)ViewData["TotalPages"] < currentPage) { currentPage = 1; } ViewData["CurrentPage"] = currentPage; //signatureList = (signatureListNoSign.AsQueryable().Skip((currentPage - 1) * _pageSize).Take(_pageSize)).ToList(); signatureList = (signatureList.AsQueryable().Skip((currentPage - 1) * _pageSize).Take(_pageSize)).ToList(); //ViewData["Title"] = currentEvent.Title; ViewData["EventID"] = currentEvent.ID; } return(View(signatureList)); }