public async Task <IActionResult> Levels(DataSourceRequest command) { var levelModel = (await _courseLevelService.GetAll()) .Select(x => x.ToModel()); var gridModel = new DataSourceResult { Data = levelModel, Total = levelModel.Count() }; return(Json(gridModel)); }
public virtual async Task <CourseModel> PrepareCourseModel(CourseModel model = null) { if (model == null) { model = new CourseModel(); model.Published = true; } foreach (var item in await _courseLevelService.GetAll()) { model.AvailableLevels.Add(new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem() { Text = item.Name, Value = item.Id }); } return(model); }
public virtual async Task <CourseModel> PrepareCourseModel(CourseModel model = null) { if (model == null) { model = new CourseModel(); model.Published = true; } foreach (var item in await _courseLevelService.GetAll()) { model.AvailableLevels.Add(new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem() { Text = item.Name, Value = item.Id }); } if (!string.IsNullOrEmpty(model.ProductId)) { var productService = _serviceProvider.GetRequiredService <IProductService>(); model.ProductName = (await productService.GetProductById(model.ProductId))?.Name; } return(model); }