public virtual ActionResult List(DataSourceRequest command, IdeaListModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageIdea)) { return(AccessDeniedKendoGridJson()); } DateTime?createOnFromValue = (model.CreatedOnFrom == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.CreatedOnFrom.Value, _dateTimeHelper.CurrentTimeZone); DateTime?createOnToValue = (model.CreatedOnTo == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.CreatedOnTo.Value, _dateTimeHelper.CurrentTimeZone); var ideas = _ideaService.GetAllIdeas(null, createOnFromValue, createOnToValue, command.Page - 1, command.PageSize); var gridModel = new DataSourceResult { Data = ideas.Select(idea => new IdeaModel { Id = idea.Id, Guid = idea.Guid, Private = idea.Private, Deleted = idea.Deleted, Body = idea.Body, CustomerEmail = idea.Customer != null ? idea.Customer.Email : null, CreatedOn = _dateTimeHelper.ConvertToUserTime(idea.CreatedOnUtc, DateTimeKind.Utc), UpdatedOn = idea.UpdatedOnUtc.HasValue ? (DateTime?)_dateTimeHelper.ConvertToUserTime(idea.UpdatedOnUtc.Value, DateTimeKind.Utc) : null }), Total = ideas.TotalCount }; return(Json(gridModel)); }
public async Task <IActionResult> Get(int page) { var userID = (await Functions.GetCurrentUser(HttpContext, _userRepository)).id; var ideas = await _repository.Query().Where(c => c.idUsers == userID). OrderByDescending(c => c.impact + c.ease + c.confidence). Skip(Math.Max(0, (page - 1)) * 10).Take(10).ToListAsync(); if (!ideas.Any()) { return(NotFound()); } var result = new IdeaListModel { Ideas = ideas.Select(idea => new IdeaModel { id = idea.id, content = idea.content, impact = idea.impact, ease = idea.ease, confidence = idea.confidence, average_score = ((float)idea.impact + (float)idea.ease + (float)idea.confidence) / 3, created_at = idea.created_at.Ticks }) }; return(Ok(result)); }
public virtual ActionResult List() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageIdea)) { return(AccessDeniedView()); } var model = new IdeaListModel(); return(View(model)); }