Exemplo n.º 1
0
        public static ICollection <GemShapeMeasurements> GemShapeMeasurementsData()
        {
            GemShapeMeasurements measure1 = new GemShapeMeasurements
            {
                GemShapeMesurementsID = 2,
                Depth     = 3.81M,
                Diameters = { new GemDiameterMeasurement {
                                  GemDiameterMeasurementsID = 1, GemShapeMesurementsID = 2, Diameter = 6
                              },
                              new GemDiameterMeasurement {
                                  GemDiameterMeasurementsID = 2, GemShapeMesurementsID = 2, Diameter = 6.11M
                              },
                              new GemDiameterMeasurement {
                                  GemDiameterMeasurementsID = 3, GemShapeMesurementsID = 2, Diameter = 6.10M
                              },
                              new GemDiameterMeasurement {
                                  GemDiameterMeasurementsID = 4, GemShapeMesurementsID = 2, Diameter = 6.32M
                              },
                              new GemDiameterMeasurement {
                                  GemDiameterMeasurementsID = 5, GemShapeMesurementsID = 2, Diameter = 6.12M
                              } }
            };
            GemShapeMeasurements measure2 =
                new GemShapeMeasurements
            {
                GemShapeMesurementsID = 2,
                Depth     = 3.81M,
                Diameters =
                {
                    new GemDiameterMeasurement {
                        GemDiameterMeasurementsID = 6, GemShapeMesurementsID = 3, Diameter = 8
                    },
                    new GemDiameterMeasurement {
                        GemDiameterMeasurementsID = 6, GemShapeMesurementsID = 3, Diameter = 12
                    },
                    new GemDiameterMeasurement {
                        GemDiameterMeasurementsID = 7, GemShapeMesurementsID = 3, Diameter = 10
                    }
                }
            };
            ICollection <GemShapeMeasurements> returnValue = new List <GemShapeMeasurements>();

            returnValue.Add(measure1);
            returnValue.Add(measure2);
            return(returnValue);
        }
Exemplo n.º 2
0
            public static decimal GemWeight(GemShape shape, GemStoneType gem, GemShapeMeasurements measurements)
            {
                var m = measurements.Diameters.GroupBy(d => d.GemShapeMesurementsID)
                        .Select(n => new
                {
                    Count   = n.Count(),
                    Average = n.Average(d => d.Diameter),
                    Max     = n.Max(d => d.Diameter),
                    Min     = n.Min(d => d.Diameter)
                });

                int c = measurements.Diameters.Count();

                if (c >= 2)
                {
                    var a = measurements.Diameters.Average(s => s.Diameter);
                }

                var width  = measurements.Diameters.Min(s => s.Diameter);
                var length = measurements.Diameters.Max(s => s.Diameter);

                return(GemWeight(shape, gem, measurements.Depth, length, width));
            }