public async Task <IList <CommunityForGoodList> > getCommunitiesForGood(long UserId) { IList <CommunityForGoodList> list = new List <CommunityForGoodList>(); await _context.LoadStoredProc("GetCommunitiesForGood") .WithSqlParam("UserId", UserId) .ExecuteStoredProcAsync((handler) => { list = handler.ReadToList <CommunityForGoodList>(); // do something with your results. }); long _lastId = 0; foreach (var item in list.ToList().OrderBy(c => c.Id).OrderByDescending(c => c.TotalMembers)) { if (item.Id == _lastId) { list.Remove(item); _lastId = 0; } else { _lastId = item.Id; } } return(list); }
public async Task <IList <CommunityGroupsListViewModel> > getCommunitiesGroupsList(SearchFilter model) { IList <CommunityGroupsListViewModel> list = new List <CommunityGroupsListViewModel>(); await _context.LoadStoredProc("GetUserCommunitiesGroupsList") .WithSqlParam("UserId", model.Id) .WithSqlParam("Start", model.PageNumber) .WithSqlParam("PageLimit", model.PageLimit) .WithSqlParam("OrderBy", model.OrderBy) .WithSqlParam("SearchValue", model.SearchValue) .ExecuteStoredProcAsync((handler) => { list = handler.ReadToList <CommunityGroupsListViewModel>(); // do something with your results. }); return(list); }
public async Task <IList <EventCommentsList> > GetEventCommentsAsync(long ArticleId, long UserId) { IList <EventCommentsList> list = new List <EventCommentsList>(); await _context.LoadStoredProc("GetEventComments") .WithSqlParam("EventId", ArticleId) .WithSqlParam("UserId", UserId) .ExecuteStoredProcAsync((handler) => { list = handler.ReadToList <EventCommentsList>(); // do something with your results. }); return(list); }
public async Task <IList <RoleViewModel> > GetList(SearchFilter model) { IList <RoleViewModel> list = new List <RoleViewModel>(); await _context.LoadStoredProc("GetRolesList") .WithSqlParam("Start", model.PageNumber) .WithSqlParam("PageLimit", model.PageLimit) .WithSqlParam("OrderBy", model.OrderBy) .ExecuteStoredProcAsync((handler) => { list = handler.ReadToList <RoleViewModel>(); // do something with your results. }); return(list); }
/// <summary> /// Save and update data in Open Office Hours table /// </summary> /// <param name="model"></param> /// <param name="user">if user model is null then please pass UserId into the OpenOfficeHoursViewModel</param> /// <param name="communityGroupsData">if communityGroupsData model is null then please pass CommunityGroupId into the OpenOfficeHoursViewModel</param> /// <returns></returns> public async Task <BaseModel> SaveOpenHoursAsync(OpenOfficeHoursViewModel model, UsersLoginDataModel user, CommunityGroupsDataModel communityGroupsData) { if (user == null) { user = await _unitOfWork.UserLoginRepository.GetByID(model.UserId); } if (communityGroupsData == null) { communityGroupsData = await _unitOfWork.UserCommunityGroupsRepository.GetByID(model.CommunityGroupId); } if (model.Id == 0) { CommunityOpenOfficeHours dataModel = new CommunityOpenOfficeHours { CreatedBy = user.Id, User = user, CommunityGroups = communityGroupsData, OTitle = model.OTitle, OName = model.OName, ODescription = model.ODescription, OFrequency = model.OFrequency, OFromDate = model.OFromDate, // setDateFromDayName(model.OTimeDayName, model.OFromDate), OToDate = model.OFromDate, // setDateFromDayName(model.OTimeDayName, model.OFromDate), OTime = model.OTime, OTimeDayName = model.OTimeDayName, OTimeZone = model.OTimeZone, MaxAttendees = model.MaxAttendees, WhoCanAttend = model.WhoCanAttend, IsActive = true, IsFirstMeeting = model.IsFirstMeeting, NextMeetingToken = model.NextMeetingToken, LastSessionId = model.LastSessionId, AddHours = model.AddHours }; await _unitOfWork.UserCommunityOpenOfficeHoursRepository.Insert(dataModel); if (model.AddHours) { await _context.LoadStoredProc("AddHoursInOpenOfficeHours") .WithSqlParam("Id", dataModel.Id) .ExecuteStoredProcAsync((handler) => { // do something with your results. }); } return(new BaseModel { Status = true, Id = dataModel.Id, Messsage = UMessagesInfo.RecordSaved }); } else { var openOfficeHoursModel = await _unitOfWork.UserCommunityOpenOfficeHoursRepository.GetByID(model.Id); openOfficeHoursModel.OTitle = model.OTitle; openOfficeHoursModel.OName = model.OName; openOfficeHoursModel.ODescription = model.ODescription; openOfficeHoursModel.OFrequency = model.OFrequency; if (openOfficeHoursModel.OTimeDayName.ToLower().Trim() != model.OTimeDayName.ToLower().Trim()) { openOfficeHoursModel.OFromDate = SphixHelper.setDateFromDayName(model.OTimeDayName, DateTime.Now.Date); openOfficeHoursModel.OToDate = openOfficeHoursModel.OFromDate; } else { openOfficeHoursModel.OFromDate = model.OFromDate;// setDateFromDayName(model.OTimeDayName, model.OFromDate); openOfficeHoursModel.OToDate = openOfficeHoursModel.OFromDate; } openOfficeHoursModel.OTime = model.OTime; openOfficeHoursModel.OTimeDayName = model.OTimeDayName; openOfficeHoursModel.OTimeZone = model.OTimeZone; openOfficeHoursModel.MaxAttendees = model.MaxAttendees; openOfficeHoursModel.WhoCanAttend = model.WhoCanAttend; openOfficeHoursModel.IsActive = true; //openOfficeHoursModel.AddHours = model.AddHours; //openOfficeHoursModel.IsFirstMeeting = model.IsFirstMeeting; await _unitOfWork.UserCommunityOpenOfficeHoursRepository.Update(openOfficeHoursModel); return(new BaseModel { Status = true, Id = model.Id, Messsage = UMessagesInfo.RecordSaved }); } }