public HttpResponseMessage GetUserCreditsPaginated([FromUri] PaginatedRequest model) { PaginatedItemsResponse <UserCredits> response = _CreditsService.GetTransactionsPaginated(model); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
private PaginatedItemsResponse MapToResponse(List <eShop.ProductEntities.Entities.Product> items, long count, int pageIndex, int pageSize) { var result = new PaginatedItemsResponse() { Count = count, PageIndex = pageIndex, PageSize = pageSize, }; items.ForEach(i => { result.Data.Add(new ProductListResponse { Id = i.ExternalId.ToString(), Name = i.Name, Category = GetCategory(i), Brand = GetBrand(i), Price = (double)i.Price, Discount = i.Discount, DiscountPrice = (double)i.DiscountPrice, AvailableStock = i.AvailableStock }); }); return(result); }
//Single Get for getting all data with queries/pagination public PaginatedItemsResponse <Job> GetAllJobsWithFilter(PaginatedRequest model) { List <Job> JobList = null; PaginatedItemsResponse <Job> response = null; DataProvider.ExecuteCmd(GetConnection, "dbo.Jobs_SelectAll" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@CurrentPage", model.CurrentPage); paramCollection.AddWithValue("@ItemsPerPage", model.ItemsPerPage); paramCollection.AddWithValue("@Query", model.Query); paramCollection.AddWithValue("@QueryWebsiteId", model.QueryWebsiteId); paramCollection.AddWithValue("@QueryStatus", model.QueryStatus); paramCollection.AddWithValue("@QueryJobType", model.QueryJobType); paramCollection.AddWithValue("@QueryStartDate", model.QueryStartDate); paramCollection.AddWithValue("@QueryEndDate", model.QueryEndDate); }, map : delegate(IDataReader reader, short set) { if (set == 0) { Job SingleJob = new Job(); int startingIndex = 0; //startingOrdinal SingleJob.Id = reader.GetSafeInt32(startingIndex++); SingleJob.UserId = reader.GetSafeString(startingIndex++); SingleJob.JobStatus = reader.GetSafeEnum <JobStatus>(startingIndex++); SingleJob.JobType = reader.GetSafeEnum <JobsType>(startingIndex++); SingleJob.Price = reader.GetSafeDecimal(startingIndex++); SingleJob.Phone = reader.GetSafeString(startingIndex++); SingleJob.JobRequest = reader.GetSafeInt32(startingIndex++); SingleJob.SpecialInstructions = reader.GetSafeString(startingIndex++); SingleJob.Created = reader.GetSafeDateTime(startingIndex++); SingleJob.Modified = reader.GetSafeDateTime(startingIndex++); SingleJob.WebsiteId = reader.GetSafeInt32(startingIndex++); if (JobList == null) { JobList = new List <Job>(); } JobList.Add(SingleJob); } else if (set == 1) { response = new PaginatedItemsResponse <Job>(); response.TotalItems = reader.GetSafeInt32(0); } } ); response.Items = JobList; response.CurrentPage = model.CurrentPage; response.ItemsPerPage = model.ItemsPerPage; return(response); }
public PaginatedItemsResponse <UserCredits> GetTransactionsPaginated(PaginatedRequest model) { List <UserCredits> TransactionsList = null; PaginatedItemsResponse <UserCredits> response = null; DataProvider.ExecuteCmd(GetConnection, "dbo.UserCredits_SelectAll" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@CurrentPage", model.CurrentPage); paramCollection.AddWithValue("@ItemsPerPage", model.ItemsPerPage); paramCollection.AddWithValue("@Query", model.Query); }, map : delegate(IDataReader reader, short set) { if (set == 0) { UserCredits data = new UserCredits(); int startingIndex = 0; //startingOrdinal data.Id = reader.GetSafeInt32(startingIndex++); data.UserId = reader.GetSafeString(startingIndex++); data.Amount = reader.GetSafeDecimal(startingIndex++); data.TransactionId = reader.GetSafeInt32(startingIndex++); data.JobId = reader.GetSafeInt32(startingIndex++); data.DateAdded = reader.GetSafeDateTime(startingIndex++); UserMini User = new UserMini(); User.FirstName = reader.GetSafeString(startingIndex++); User.LastName = reader.GetSafeString(startingIndex++); User.Email = reader.GetSafeString(startingIndex++); User.Phone = reader.GetSafeString(startingIndex++); User.Url = reader.GetSafeString(startingIndex++); data.User = User; if (TransactionsList == null) { TransactionsList = new List <UserCredits>(); } TransactionsList.Add(data); } else if (set == 1) { response = new PaginatedItemsResponse <UserCredits>(); response.TotalItems = reader.GetSafeInt32(0); } } ); response.Items = TransactionsList; response.CurrentPage = model.CurrentPage; response.ItemsPerPage = model.ItemsPerPage; return(response); }
public HttpResponseMessage GetAllJobsWithFilter([FromUri] PaginatedRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } PaginatedItemsResponse <Job> response = _JobsService.GetAllJobsWithFilter(model); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public HttpResponseMessage GetAllReferralPagination([FromUri] PaginatedRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } string UserId = UserService.GetCurrentUserId(); PaginatedItemsResponse <Token> response = TokenService.getTokenByUserIdAndTokenTypePagination(UserId, model); response.CurrentPage = model.CurrentPage; response.ItemsPerPage = model.ItemsPerPage; return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public string ExportCsv(PaginatedRequest model) { PaginatedItemsResponse <RegistrationReport> response = GetReportByDateAndWebId(model); StringBuilder sb = new StringBuilder(); string csvHeader = "Date, Website Id, Website Name, Total Registered, Total Referrals"; //this is the header for the excel columns sb.AppendLine(csvHeader); foreach (var item in response.Items) // for each item in the response, it will build a line of strings within the columns of the csvHeader { sb.AppendLine(String.Format("{0},{1},{2},{3},{4}", item.Date, item.WebsiteId, item.Name, item.TotalRegistered, item.TotalReferrals)); } return(sb.ToString()); //appends every line into a string }
private PaginatedItemsResponse MapToResponse(List <CatalogItem> items, long count, int pageIndex, int pageSize) { var result = new PaginatedItemsResponse() { Count = count, PageIndex = pageIndex, PageSize = pageSize, }; items.ForEach(i => { var brand = i.CatalogBrand == null ? null : new CatalogApi.CatalogBrand() { Id = i.CatalogBrand.Id, Name = i.CatalogBrand.Brand, }; var catalogType = i.CatalogType == null ? null : new CatalogApi.CatalogType() { Id = i.CatalogType.Id, Type = i.CatalogType.Type, }; result.Data.Add(new CatalogItemResponse() { AvailableStock = i.AvailableStock, Description = i.Description, Id = i.Id, MaxStockThreshold = i.MaxStockThreshold, Name = i.Name, OnReorder = i.OnReorder, PictureFileName = i.PictureFileName, PictureUri = i.PictureUri, RestockThreshold = i.RestockThreshold, CatalogBrand = brand, CatalogType = catalogType, Price = (double)i.Price, }); }); return(result); }
//Update to the Paginated get page public static PaginatedItemsResponse <Token> getTokenByUserIdAndTokenTypePagination(string UserId, PaginatedRequest model) { List <Token> list = null; PaginatedItemsResponse <Token> response = null; DataProvider.ExecuteCmd(GetConnection, "dbo.Token_SelectAll_v3" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@UserId", UserId); paramCollection.AddWithValue("@TokenType", TokenType.Invite); paramCollection.AddWithValue("@CurrentPage", model.CurrentPage); paramCollection.AddWithValue("@ItemsPerPage", model.ItemsPerPage); } , map : delegate(IDataReader reader, short set) { if (set == 0) { int startingIndex = 0; Token c = new Token(); c.Id = reader.GetSafeInt32(startingIndex++); c.DateCreated = reader.GetSafeDateTime(startingIndex++); c.Used = reader.GetSafeDateTimeNullable(startingIndex++); c.UserId = reader.GetSafeString(startingIndex++); c.TokenType = reader.GetSafeInt32(startingIndex++); c.CouponId = reader.GetSafeInt32(startingIndex++); c.Email = reader.GetSafeString(startingIndex++); if (list == null) { list = new List <Token>(); } list.Add(c); } else if (set == 1) { response = new PaginatedItemsResponse <Token>(); response.TotalItems = reader.GetSafeInt32(0); } } ); response.Items = list; return(response); }
public HttpResponseMessage GetFilteredReport([FromUri] PaginatedRequest model) { if (model.querystartdate == null) { model = new paginatedrequest(); model.querystartdate = datetime.now.adddays(-14); model.queryenddate = datetime.now; } bool forRender = _AdminReportService.ForRender(model); bool forCsv = _AdminReportService.ForCsv(model); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); PaginatedItemsResponse <RegistrationReport> response = _AdminReportService.GetReportByDateAndWebId(model); result = Request.CreateResponse(HttpStatusCode.OK, response); return(result); }
public PaginatedItemsResponse <RegistrationReport> GetReportByDateAndWebId(PaginatedRequest model) { List <RegistrationReport> reportList = null; PaginatedItemsResponse <RegistrationReport> response = null; DataProvider.ExecuteCmd(GetConnection, "dbo.Reports_UserRegistrationReport_GetByDateAndWebId_v2" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@QueryWebsiteId", model.QueryWebsiteId); paramCollection.AddWithValue("@QueryStartDate", model.QueryStartDate); paramCollection.AddWithValue("@QueryEndDate", model.QueryEndDate); }, map : delegate(IDataReader reader, short set) { if (set == 0) { RegistrationReport report = new RegistrationReport(); int startingIndex = 0; report.Date = reader.GetSafeDateTime(startingIndex++); report.WebsiteId = reader.GetSafeInt32(startingIndex++); report.TotalRegistered = reader.GetSafeInt32(startingIndex++); report.TotalReferrals = reader.GetSafeInt32(startingIndex++); report.Name = reader.GetSafeString(startingIndex++); if (reportList == null) { reportList = new List <RegistrationReport>(); } reportList.Add(report); } else if (set == 1) { response = new PaginatedItemsResponse <RegistrationReport>(); response.TotalItems = reader.GetSafeInt32(0); } } ); response.Items = reportList; return(response); }
private PaginatedItemsResponse MapToResponse(List <ServiceListItem> items, long count, int pageIndex, int pageSize) { var result = new PaginatedItemsResponse() { Count = count, PageIndex = pageIndex, PageSize = pageSize, }; items.ForEach(i => { result.Data.Add(new ServiceListItemResponse() { Description = i.Description, Id = i.Id, Name = i.Name, Price = (double)i.Price, }); }); return(result); }
public override async Task <PaginatedItemsResponse> GetUsers(UsersRequest request, ServerCallContext context) { var list = await _userManager.Users .OrderBy(u => u.UserName) .Skip(request.PageIndex * request.PageSize) .Take(request.PageSize) .Select(u => new UsersResponse { Id = u.Id, UserName = u.UserName }) .ToListAsync(); var totalItems = await _userManager.Users.LongCountAsync(); var resp = new PaginatedItemsResponse { Count = totalItems, PageIndex = request.PageIndex, PageSize = request.PageSize }; resp.Data.AddRange(list); return(resp); }
private PaginatedItemsResponse MapToResponse(List <ScholarshipItem> items, long count, int pageIndex, int pageSize) { var result = new PaginatedItemsResponse() { Count = count, PageIndex = pageIndex, PageSize = pageSize, }; items.ForEach(i => { var scholarshipcurrency = i.ScholarshipCurrency == null ? null : new ScholarshipApi.ScholarshipCurrency() { Id = i.ScholarshipCurrency.Id, Symbol = i.ScholarshipCurrency.Symbol, Code = i.ScholarshipCurrency.Code, Currency = i.ScholarshipCurrency.Currency, }; var scholarshipduration = i.ScholarshipDuration == null ? null : new ScholarshipApi.ScholarshipDuration() { Id = i.ScholarshipDuration.Id, Duration = i.ScholarshipDuration.Duration, }; var scholarshipeducationLevel = i.ScholarshipEducationLevel == null ? null : new ScholarshipApi.ScholarshipEducationLevel() { Id = i.ScholarshipEducationLevel.Id, EducationLevel = i.ScholarshipEducationLevel.EducationLevel, }; var scholarshipinterest = i.ScholarshipInterest == null ? null : new ScholarshipApi.ScholarshipInterest() { Id = i.ScholarshipInterest.Id, Interest = i.ScholarshipInterest.Interest, }; var scholarshiplocation = i.ScholarshipLocation == null ? null : new ScholarshipApi.ScholarshipLocation() { Id = i.ScholarshipLocation.Id, Location = i.ScholarshipLocation.Location, }; result.Data.Add(new ScholarshipItemResponse() { AvailableSlots = i.AvailableSlots, Description = i.Description, Id = i.Id, MaxSlotsThreshold = i.MaxSlotThreshold, Name = i.Name, OnReapply = i.OnReapply, PictureFileName = i.PictureFileName, PictureUri = i.PictureUri, ReslotThreshold = i.ReslotThreshold, ScholarshipCurrency = scholarshipcurrency, ScholarshipDuration = scholarshipduration, ScholarshipEducationLevel = scholarshipeducationLevel, ScholarshipInterest = scholarshipinterest, ScholarshipLocation = scholarshiplocation, Amount = (double)i.Amount, }); }); return(result); }
public PaginatedItemsResponse <ActivityLogAll> GetAllDetails(PaginatedRequest model) { List <ActivityLogAll> list = null; PaginatedItemsResponse <ActivityLogAll> response = null; DataProvider.ExecuteCmd(GetConnection, "ActivityLog_SelectAllForSearchFourTables" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@CurrentPage", model.CurrentPage); paramCollection.AddWithValue("@ItemsPerPage", model.ItemsPerPage); paramCollection.AddWithValue("@Selector", model.Selector); } , map : delegate(IDataReader reader, short set) { if (set == 0) { ActivityLogAll a = new ActivityLogAll(); int startingIndex = 0; //startingOrdinal a.ActivityLog.Id = reader.GetSafeInt32(startingIndex++); a.ActivityLog.UserId = reader.GetSafeString(startingIndex++); a.ActivityLog.ActivityTypeId = reader.GetSafeEnum <ActivityTypeId>(startingIndex++); a.ActivityLog.JobId = reader.GetSafeInt32(startingIndex++); a.ActivityLog.TargetValue = reader.GetSafeInt32(startingIndex++); a.ActivityLog.IdCreated = reader.GetSafeDateTime(startingIndex++); a.User.UserProfileId = reader.GetSafeInt32(startingIndex++); a.User.FirstName = reader.GetSafeString(startingIndex++); a.User.LastName = reader.GetSafeString(startingIndex++); a.User.ExternalUserId = reader.GetSafeString(startingIndex++); a.User.DateCreated = reader.GetSafeDateTime(startingIndex++); a.User.DateModified = reader.GetSafeDateTime(startingIndex++); a.User.MediaId = reader.GetSafeInt32(startingIndex++); a.User.Email = reader.GetSafeString(startingIndex++); a.User.Phone = reader.GetSafeString(startingIndex++); a.User.Role.RoleId = reader.GetSafeString(startingIndex++); a.User.Role.Name = reader.GetSafeString(startingIndex++); a.Media.Url = reader.GetSafeString(startingIndex++); a.Jobs.Id = reader.GetSafeInt32(startingIndex++); a.Jobs.JobStatus = reader.GetSafeEnum <JobStatus>(startingIndex++); a.Jobs.JobType = reader.GetSafeEnum <JobsType>(startingIndex++); a.Jobs.Price = reader.GetSafeDecimal(startingIndex++); a.Jobs.JobRequest = reader.GetSafeInt32(startingIndex++); a.Jobs.ContactName = reader.GetSafeString(startingIndex++); a.Jobs.Phone = reader.GetSafeString(startingIndex++); a.Jobs.SpecialInstructions = reader.GetSafeString(startingIndex++); a.Jobs.Created = reader.GetSafeDateTime(startingIndex++); a.Jobs.Modified = reader.GetSafeDateTime(startingIndex++);; if (list == null) { list = new List <ActivityLogAll>(); } list.Add(a); } else if (set == 1) { response = new PaginatedItemsResponse <ActivityLogAll>(); response.TotalItems = reader.GetSafeInt32(0); } } ); response.Items = list; response.CurrentPage = model.CurrentPage; response.ItemsPerPage = model.ItemsPerPage; return(response); }
// Get by website slug - website, media, address public static PaginatedItemsResponse <WebsiteSettings> GetSettingsByQuery(PaginatedRequest model) { List <WebsiteSettings> list = null; PaginatedItemsResponse <WebsiteSettings> response = null; DataProvider.ExecuteCmd(GetConnection, "dbo.WebsiteSettings_GetByWebsiteSlug_Query" , inputParamMapper : delegate(SqlParameterCollection paramCollection) { paramCollection.AddWithValue("@Slug", model.Slug); paramCollection.AddWithValue("@CurrentPage", model.CurrentPage); paramCollection.AddWithValue("@ItemsPerPage", model.ItemsPerPage); paramCollection.AddWithValue("@Query", model.Query); paramCollection.AddWithValue("@QueryCategory", model.QueryCategory); paramCollection.AddWithValue("@QuerySettingSection", model.QuerySettingSection); paramCollection.AddWithValue("@QuerySettingType", model.QuerySettingType); }, map : delegate(IDataReader reader, short set) { if (set == 0) { int startingIndex = 0; WebsiteSettings ws = new WebsiteSettings(); ws.Id = reader.GetSafeInt32(startingIndex++); ws.SettingsId = reader.GetSafeInt32(startingIndex++); ws.WebsiteId = reader.GetSafeInt32(startingIndex++); ws.SettingsValue = reader.GetSafeString(startingIndex++); ws.UserId = reader.GetSafeString(startingIndex++); ws.MediaId = reader.GetSafeInt32(startingIndex++); ws.DateAdded = reader.GetSafeDateTime(startingIndex++); ws.DateModified = reader.GetSafeDateTime(startingIndex++); Website c = new Website(); c.Id = reader.GetSafeInt32(startingIndex++); c.Name = reader.GetSafeString(startingIndex++); c.Slug = reader.GetSafeString(startingIndex++); c.Description = reader.GetSafeString(startingIndex++); c.Url = reader.GetSafeString(startingIndex++); c.MediaId = reader.GetSafeInt32(startingIndex++); c.DateCreated = reader.GetSafeDateTime(startingIndex++); c.DateModified = reader.GetSafeDateTime(startingIndex++); c.Phone = reader.GetSafeString(startingIndex++); if (c.Id != 0) { ws.Website = c; } Settings s = new Settings(); s.Id = reader.GetSafeInt32(startingIndex++); s.Category = reader.GetSafeEnum <SettingsCategory>(startingIndex++); s.Name = reader.GetSafeString(startingIndex++); s.DateCreated = reader.GetSafeDateTime(startingIndex++); s.DateModified = reader.GetSafeDateTime(startingIndex++); s.SettingType = reader.GetSafeEnum <SettingsType>(startingIndex++); s.Description = reader.GetSafeString(startingIndex++); s.SettingSlug = reader.GetSafeString(startingIndex++); s.SettingSection = reader.GetSafeEnum <SettingsSection>(startingIndex++); if (s.Id != 0) { ws.Setting = s; } Media m = new Media(); m.Id = reader.GetSafeInt32(startingIndex++); m.Url = reader.GetSafeString(startingIndex++); m.MediaType = reader.GetSafeInt32(startingIndex++); m.UserId = reader.GetSafeString(startingIndex++); m.Title = reader.GetSafeString(startingIndex++); m.Description = reader.GetSafeString(startingIndex++); m.ExternalMediaId = reader.GetSafeInt32(startingIndex++); m.FileType = reader.GetSafeString(startingIndex++); m.DateCreated = reader.GetSafeDateTime(startingIndex++); m.DateModified = reader.GetSafeDateTime(startingIndex++); if (m.Id != 0) { ws.Media = m; } if (list == null) { list = new List <WebsiteSettings>(); } list.Add(ws); } else if (set == 1) { response = new PaginatedItemsResponse <WebsiteSettings>(); response.TotalItems = reader.GetSafeInt32(0); } } ); response.Items = list; response.CurrentPage = model.CurrentPage; response.ItemsPerPage = model.ItemsPerPage; response.Query = model.Query; return(response); }