Пример #1
0
        private void CheckParabola(UserData ud)
        {
            if (CheckData(ud))
            {
                int _chartid;
                using (MdaBdContext db = new MdaBdContext())
                {
                    db.UserDatas.Add(ud);
                    db.SaveChanges();
                    var userdata = db.UserDatas.Max(x => x.Id_UD);
                    _chartid = userdata;
                }

                List <Point> ds = new List <Point>();
                Point        pt = new Point();
                for (float i = ud.RangeFrom; i <= ud.RangeTo; i += ud.Step)
                {
                    pt = new Point
                    {
                        x       = i,
                        y       = (ud.A * (i * i) + ud.B * i + ud.C),
                        ChartId = _chartid
                    };

                    ds.Add(pt);
                }
                AddToDb(ds, ud);
                pt.Serializer(ds);
            }
        }
Пример #2
0
 private void AddToDb(List <Point> listofPoints, UserData userData)
 {
     using (MdaBdContext db = new MdaBdContext())
     {
         foreach (Point point in listofPoints)
         {
             db.Points.Add(point);
         }
         db.SaveChanges();
     }
 }