public async Task <IActionResult> GetEventsAsync([FromQuery] PaginationFilter paginationFilter, [FromBody] EventFilterModel filter) { if (filter == null) { return(BadRequest()); } var models = await _eventService.GetEventsAsync(filter); if (models == null) { return(Json(new { status = "error", message = "Couldn't load events" })); } var pagedResponse = PaginationHelper.ToPagedResponse(models, paginationFilter, models.Count); return(Ok(pagedResponse)); }
public async Task <ActionResult <IEnumerable <Event> > > GetEvents(int portalId, EventFilterModel filters = null) { IEnumerable <Event> events = await _eventRepository.GetEvents(portalId, filters); return(Ok(events)); }
public EventFilterViewModel GetEventFilteredData([FromBody] EventFilterModel eventData) { return(this._eventRepository.GetAllEventData(eventData, base.UserId, base.OrganizationId)); }
public EventFilterViewModel GetAllEventData(EventFilterModel filterModel, int Userid, int OrganizationId) { DbDataReader reader = null; EventFilterViewModel model = new EventFilterViewModel(); try { RepositoryContext.Database.Initialize(force: false); var cmd = RepositoryContext.Database.Connection.CreateCommand(); cmd.CommandText = "SP_GetAllEventData"; cmd.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter parm1 = new SqlParameter(); parm1.ParameterName = "@type"; parm1.Value = filterModel.type; parm1.SqlDbType = SqlDbType.Int; SqlParameter parm2 = new SqlParameter(); parm2.ParameterName = "@subType"; parm2.Value = filterModel.subType; parm2.SqlDbType = SqlDbType.Int; SqlParameter parm3 = new SqlParameter(); parm3.ParameterName = "@viewType"; parm3.Value = filterModel.viewType; parm3.SqlDbType = SqlDbType.VarChar; SqlParameter parm4 = new SqlParameter(); parm4.ParameterName = "@selectedDate"; parm4.Value = filterModel.date; parm4.SqlDbType = SqlDbType.VarChar; SqlParameter parm5 = new SqlParameter(); parm5.ParameterName = "@OrganizationId"; parm5.Value = OrganizationId; parm5.SqlDbType = SqlDbType.Int; cmd.Parameters.Add(parm1); cmd.Parameters.Add(parm2); cmd.Parameters.Add(parm3); cmd.Parameters.Add(parm4); cmd.Parameters.Add(parm5); if (RepositoryContext.Database.Connection.State == ConnectionState.Closed) { RepositoryContext.Database.Connection.Open(); } reader = cmd.ExecuteReader(); model.EventDataModel = (from n in ((IObjectContextAdapter)RepositoryContext) .ObjectContext.Translate <EventDataModel>(reader) select n).ToList(); reader.NextResult(); model.EventAttendeeDataModel = (from n in ((IObjectContextAdapter)RepositoryContext) .ObjectContext.Translate <EventAttendeeDataModel>(reader) select n).ToList(); reader.NextResult(); model.ActionDataModel = (from n in ((IObjectContextAdapter)RepositoryContext) .ObjectContext.Translate <ActionDataModel>(reader) select n).ToList(); reader.NextResult(); model.AgendaDataModel = (from n in ((IObjectContextAdapter)RepositoryContext) .ObjectContext.Translate <AgendaDataModel>(reader) select n).ToList(); if (model.ActionDataModel != null && model.ActionDataModel.Any()) { foreach (ActionDataModel actionModel in model.ActionDataModel) { var data = this._IActionResponsiblePersonRepository.GetByActionId(actionModel.ActionID, Userid, OrganizationId); actionModel.ActionResponsiblePersonDataModel = Mapper.Map <List <ActionResponsiblePerson>, List <ActionResponsiblePersonDataModel> >(data); } } } finally { if (reader != null) { if (!reader.IsClosed) { reader.Close(); } } if (RepositoryContext.Database.Connection.State == ConnectionState.Open) { RepositoryContext.Database.Connection.Close(); RepositoryContext.Database.Connection.Dispose(); } } return(model); }
private IQueryable <EventUserModel> CreateUserEventsQueryWithFiltration(string userId, EventFilterModel filterModel) { var query = CreateUserEventsQuery(userId).Where(x => x.State == EventState.Seen); if (filterModel.UserIds != null && filterModel.UserIds.Any()) { query = query.Where(x => filterModel.UserIds.Contains(x.EventCreaterId)); } if (filterModel.IsFavorite.HasValue) { query = query.Where(x => x.IsFavorite == filterModel.IsFavorite.Value); } if (filterModel.ItemsIds != null) { var parsedIds = filterModel.ItemsIds.Trim().Split(',').Select(x => x.Trim()).ToArray(); var intIds = new List <int>(); foreach (var parsedId in parsedIds) { int id; if (int.TryParse(parsedId, out id)) { intIds.Add(id); } } if (intIds.Any()) { query = query.Where(x => x.ObjectId.HasValue && intIds.Contains(x.ObjectId.Value)); } } if (filterModel.DateRange.Start != default(DateTime)) { query = query.Where(x => x.Date >= filterModel.DateRange.Start); } if (filterModel.DateRange.End != default(DateTime)) { if (filterModel.DateRange.Start == filterModel.DateRange.End) { query = query.Where(x => x.Date <= filterModel.DateRange.Start.AddDays(1).AddMilliseconds(-1)); } else { query = query.Where(x => x.Date <= filterModel.DateRange.End); } } return(query); }
public int GetTotalEventsForUserCount(string userId, EventFilterModel filterModel) { return(CreateUserEventsQueryWithFiltration(userId, filterModel).Count()); }