public Task <List <EquipmentModel> > Handle(GetEquipmentQuery request, CancellationToken cancellationToken) { return(context.Equipment .AsNoTracking() .ProjectTo <EquipmentModel>(mapper.ConfigurationProvider) .ToListAsync()); }
// GET: Equipment public ActionResult Index() { var query = new GetEquipmentQuery(); var equipments = mediator.Send(query); var viewModelItemList = new List <EquipmentViewModel>(); foreach (var item in equipments) { viewModelItemList.Add(new EquipmentViewModel { Id = item.Id, Name = item.Name, Code = item.Code, Status = item.Status, CreatedOn = item.CreatedOn, UsingBy = item.AssignTo }); } var viewModel = new MyEquipmentViewModel { EquimentItems = viewModelItemList.ToArray() }; return(View(viewModel)); }