Пример #1
0
        public void SaveAnimalNumber(string animalNumbers, int orderId, TrackAnimal trackAnimal)
        {
            var animalNumbersList = GetAnimalTrackingGridItems(animalNumbers);

            _coldWeightEntryService.Save(animalNumbersList, orderId, trackAnimal);

            this.ShowNotification(NotificationType.Success, "All numbers have been saved");
        }
Пример #2
0
        public static string GetEnumDescription(this TrackAnimal trackAnimal)
        {
            var type      = typeof(TrackAnimal);
            var memInfo   = type.GetMember(trackAnimal.ToString());
            var attribute = memInfo[0].GetCustomAttributes(typeof(DescriptionAttribute),
                                                           false).FirstOrDefault();

            return((attribute == null)? Enum.GetName(typeof(TrackAnimal), trackAnimal): (attribute as DescriptionAttribute).Description);
        }
Пример #3
0
        public void Save(IEnumerable <ColdWeightEntryDetailItem> newarray, int orderId, TrackAnimal trackAnimal)
        {
            var coldWeightEntry = _coldWeightEntryRepository.GetByOrderId(orderId);

            if (coldWeightEntry == null)
            {
                coldWeightEntry = new ColdWeightEntry
                {
                    OrderId       = orderId,
                    TrackAnimalId = trackAnimal
                };
                _coldWeightEntryRepository.Add(coldWeightEntry);
            }
            coldWeightEntry.TrackAnimalId = trackAnimal;
            _coldWeightEntryRepository.Save();

            List <ColdWeightEntryDetail> newColdWeightDetails = new List <ColdWeightEntryDetail>();

            foreach (var newItem in newarray)
            {
                newColdWeightDetails.Add(new ColdWeightEntryDetail
                {
                    Id               = newItem.Id,
                    ColdWeightId     = coldWeightEntry.Id,
                    AnimalNumber     = newItem.AnimalNumber,
                    EarTag           = newItem.EarTag,
                    FirstSideWeight  = newItem.FirstCustomer.CustomerLocationId,
                    SecondSideWeight = (trackAnimal == TrackAnimal.Half || trackAnimal == TrackAnimal.Quarter ||
                                        coldWeightEntry.TrackAnimalId == TrackAnimal.HalfAndTwoQuaters || coldWeightEntry.TrackAnimalId == TrackAnimal.ThreeQuatersAndQuater) ? newItem.SecondCustomer.CustomerLocationId : null,
                    ThirdSideWeight  = (trackAnimal == TrackAnimal.Quarter || trackAnimal == TrackAnimal.HalfAndTwoQuaters) ? newItem.ThirdCustomer.CustomerLocationId : null,
                    FourthSideWeight = trackAnimal == TrackAnimal.Quarter ? newItem.FourthCustomer.CustomerLocationId : null,
                    IsOrganic        = newItem.IsOrganic,
                    TrackAnimalId    = newItem.TrackAnimalBySelectColumn,
                    HotWeight        = newItem.HotWeight,
                    ColdWeight       = newItem.ColdWeight,
                    QualityGradeId   = newItem.QualityGrade.Id,
                    AnimalLabelId    = newItem.AnimalLabel.Id,
                });
            }

            if (coldWeightEntry.ColdWeightEntryDetails.Any())
            {
                var existingIds = coldWeightEntry.ColdWeightEntryDetails.Select(ord => ord.Id).ToList();
                foreach (var item in newColdWeightDetails)
                {
                    if (existingIds.Contains(item.Id))
                    {
                        _coldWeightEntryDetailRepository.Update(newColdWeightDetails.First(x => x.Id == item.Id));
                    }
                    else
                    {
                        _coldWeightEntryDetailRepository.Add(item);
                    }
                }
            }
            else
            {
                _coldWeightEntryDetailRepository.AddRange(newColdWeightDetails);
            }

            _coldWeightEntryDetailRepository.Save();
        }
Пример #4
0
        private PartialViewResult GetAnimalGridPartial(TrackAnimal trackAnimal, ColdWeightEntryDetailItem item)
        {
            ViewBag.CustomerLocations = GetCustomerLocationsByOrderId(item.OrderId);
            var animalLabels = new List <AnimalLabelsViewModel>();
            var labels       = _animalLabelRepository.FindAll(x => x.SpeciesId == item.AnimalLabel.Species.Id).ToList();

            foreach (var animalLabel in labels)
            {
                var label = new AnimalLabelsViewModel()
                {
                    Id      = animalLabel.Id,
                    Name    = animalLabel.Name,
                    Species = new SpeciesViewModel()
                    {
                        Name = animalLabel.Species.Name,
                        Id   = animalLabel.SpeciesId
                    }
                };
                animalLabels.Add(label);
            }
            if (animalLabels.Any())
            {
                item.AnimalLabel = animalLabels.FirstOrDefault();
            }
            ViewBag.AnimalLabels = animalLabels;
            var grades = _lookupService.GetQualityGrades().Select(x => new QualityGrade()
            {
                Id        = x.Id,
                Name      = x.Name,
                SortOrder = x.SortOrder
            });

            if (grades.Any())
            {
                ViewBag.QualityGrades = grades;
            }

            ViewBag.TrackAnimalByList = Enum
                                        .GetValues(typeof(TrackAnimal))
                                        .Cast <int>()
                                        .Select(i => new SelectListItem
            {
                Value = i.ToString(),
                Text  = Enum.GetName(typeof(TrackAnimal), i).GetTrackAnimailEnumDescription(i),
            }
                                                )
                                        .ToList();
            switch (trackAnimal)
            {
            case (TrackAnimal.Whole):
                return(PartialView("_AnimalTrackingGrid", item));

            case (TrackAnimal.Quarter):
                return(PartialView("_AnimalTrackingGridQuarters", item));

            case (TrackAnimal.Half):
                return(PartialView("_AnimalTrackingGridHalves", item));

            case (TrackAnimal.HalfAndTwoQuaters):
                return(PartialView("_AnimalTrakingGridHalfAndTwoQuaters", item));

            case (TrackAnimal.ThreeQuatersAndQuater):
                return(PartialView("_AnimalTrakingGridThreeQuatersAndQuater", item));

            default:
                return(new PartialViewResult());
            }
        }