private void InitLabelsValues() { var species = _speciesRepository.GetAll().ToList().Select(x => new SpeciesViewModel() { Name = x.Name, Id = x.Id }).ToList(); ViewBag.LabelTypes = species; ViewBag.DefaultLabelType = species.FirstOrDefault(); }
//get base coldweight entry public ColdWeightEntryDetailItem GetColdWeightEntryDetail(int orderId) { var customerId = _orderRepository.Get(orderId).CustomerId; var coldWeightEntry = _coldWeightEntryRepository.GetByOrderId(orderId); var qualitiesList = new SelectList(_qualityGradeRepository.GetAll().Select(x => new QualityGrade() { Id = x.Id, Name = x.Name }), "Id", "Name"); int speciesId = 0; if (coldWeightEntry != null && coldWeightEntry.ColdWeightEntryDetails != null) { var coldWeightEntryDetail = coldWeightEntry.ColdWeightEntryDetails.FirstOrDefault(); speciesId = coldWeightEntry != null && coldWeightEntry.ColdWeightEntryDetails.Any() ? coldWeightEntryDetail.AnimalLabel.SpeciesId: 0; } var species = new List <SpeciesViewModel>(_speciesRepository.GetAll().Select(x => new SpeciesViewModel() { Id = x.Id, Name = x.Name })); var speciesViewModel = species.FirstOrDefault(x => { return(speciesId != 0 && x.Id == speciesId); }); var coldweightDetailItem = new ColdWeightEntryDetailItem { AnimalLabelId = speciesViewModel != null ? speciesViewModel.Id: (int?)null, AnimalLabel = new AnimalLabelsViewModel() { Species = speciesViewModel }, TrackAnimalBy = coldWeightEntry != null ? coldWeightEntry.TrackAnimalId : TrackAnimal.Whole, OrderId = orderId, IsExist = coldWeightEntry != null && coldWeightEntry.ColdWeightEntryDetails.Any(), CustomerLocations = new SelectList(_orderDetailService.GetCustomerLocations(customerId), "CustomerLocationId", "CustomerLocationName"), SpeciesList = new SelectList(species, "Id", "Name"), QualityGradeList = qualitiesList }; return(coldweightDetailItem); }
public IEnumerable <Species> GetSpecies() { return(_speciesRepository.GetAll()); }