コード例 #1
0
 public IHttpActionResult Get()
 {
     using (var context = new GaugeDbContext())
     {
         return(Ok(context.CircularGaugeOptions
                   .Include(x => x.Ranges)
                   .Include(x => x.Scale)
                   .ToList()));
     }
 }
コード例 #2
0
        public static void Seed()
        {
            using (var context = new GaugeDbContext())
            {
                if (!context.CircularGaugeOptions.Any())
                {
                    var first = new CircularGaugeOptions()
                    {
                        Title = "4.4% / TCHF 120",
                        Scale = new Scale()
                        {
                            StartValue = 0.0m,
                            EndValue   = 0.5m,
                            MajorTick  = 0.01m
                        },
                        Value  = 0.044m,
                        Ranges = new List <Range>()
                        {
                            new Range()
                            {
                                StartValue = 0.0m, EndValue = 0.020m, Color = "#EF8C75"
                            },
                            new Range()
                            {
                                StartValue = 0.020m, EndValue = 0.027m, Color = "#FED96D"
                            },
                            new Range()
                            {
                                StartValue = 0.027m, EndValue = 0.050m, Color = "#9EC968"
                            }
                        }
                    };

                    context.CircularGaugeOptions.Add(first);
                    context.SaveChanges();
                }
            }
        }