public ActionResult FetchOrgRollList(string data) { // Authenticate first var result = AuthenticateUser(); if (!result.IsValid) { return(AuthorizationError(result)); } // Check Role if (!CMSRoleProvider.provider.IsUserInRole(AccountModel.UserName2, "Attendance")) { return(BaseMessage.createErrorReturn("Attendance roles is required to take attendance for organizations")); } // Check to see if type matches BaseMessage dataIn = BaseMessage.createFromString(data); MobilePostRollList mprl = JsonConvert.DeserializeObject <MobilePostRollList>(dataIn.data); var meetingId = DbUtil.Db.CreateMeeting(mprl.id, mprl.datetime); var people = RollsheetModel.RollList(meetingId, mprl.id, mprl.datetime); var meeting = DbUtil.Db.Meetings.SingleOrDefault(m => m.MeetingId == meetingId); MobileRollList mrl = new MobileRollList(); mrl.attendees = new List <MobileAttendee>(); mrl.meetingID = meetingId; mrl.headcountEnabled = DbUtil.Db.Setting("RegularMeetingHeadCount", "true"); mrl.headcount = meeting.HeadCount ?? 0; BaseMessage br = new BaseMessage(); br.id = meetingId; br.error = 0; br.count = people.Count(); foreach (var person in people) { mrl.attendees.Add(new MobileAttendee().populate(person)); } br.data = JsonConvert.SerializeObject(mrl); return(br); }
public ActionResult FetchOrgRollList(string data) { // Authenticate first var authError = Authenticate(); if (authError != null) { return(authError); } // Check Role if (!CMSRoleProvider.provider.IsUserInRole(AccountModel.UserName2, "Attendance")) { return(BaseMessage.createErrorReturn("Attendance roles is required to take attendance for organizations")); } // Check to see if type matches BaseMessage dataIn = BaseMessage.createFromString(data); if (dataIn.type != BaseMessage.API_TYPE_ORG_ROLL_REFRESH) { return(BaseMessage.createTypeErrorReturn()); } // Everything is in order, start the return MobilePostRollList mprl = JsonConvert.DeserializeObject <MobilePostRollList>(dataIn.data); var meeting = Meeting.FetchOrCreateMeeting(DbUtil.Db, mprl.id, mprl.datetime); var people = RollsheetModel.RollList(meeting.MeetingId, meeting.OrganizationId, meeting.MeetingDate.Value); BaseMessage br = new BaseMessage(); List <MobileAttendee> ma = new List <MobileAttendee>(); br.id = meeting.MeetingId; br.error = 0; br.type = BaseMessage.API_TYPE_ORG_ROLL_REFRESH; br.count = people.Count(); foreach (var person in people) { ma.Add(new MobileAttendee().populate(person)); } br.data = JsonConvert.SerializeObject(ma); return(br); }