/// <summary> /// Get Equipments For Material /// </summary> /// <param name="id"></param> /// <returns></returns> public IResult GetEquipmentsForMaterial(string id) { var result = new Result { Operation = Operation.Read, Status = Status.Success }; try { var equipmentViewModels = new List <EquipmentViewModel>(); var equipments = _equipmentRepository.Filter(t => t.Material == ObjectId.Parse(id)).ToList(); if (equipments.Any()) { equipmentViewModels = equipments.Select(t => { var equipmentViewModel = new EquipmentViewModel(); equipmentViewModel.MapFromModel(t); if (t.TechnicalSpecifications == null || !t.TechnicalSpecifications.Any()) { return(equipmentViewModel); } var techSpecs = new List <TechSpecsViewModel>(); equipmentViewModel.TechnicalSpecifications = techSpecs.MapFromModel <TechnicalSpecification, TechSpecsViewModel>(t.TechnicalSpecifications); return(equipmentViewModel); }).ToList(); } result.Body = equipmentViewModels; } catch (Exception e) { result.Message = e.Message; result.Status = Status.Fail; } return(result); }