Example #1
0
 public virtual void Delete(TEntity entityToDelete)
 {
     if (context.Entry(entityToDelete).State == EntityState.Detached)
     {
         dbSet.Attach(entityToDelete);
     }
     dbSet.Remove(entityToDelete);
 }
Example #2
0
        public async Task <IActionResult> PutChart(long id, Chart chart)
        {
            if (id != chart.Id)
            {
                return(BadRequest());
            }

            _context.Entry(chart).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ChartExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #3
0
 protected void ddlTrendChart_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.ddlTrendChart.SelectedValue != "")
     {
         this.txtPath1.Text           = this.ddlTrendChart.SelectedValue;
         this.img_TrendChart.ImageUrl = this.ddlTrendChart.SelectedValue;
         this.pic_div1.Visible        = true;
         using (var context = new ChartContext())
         {
             var entity = context.Gathers.FirstOrDefault(g => g.PngFilePath == this.ddlTrendChart.SelectedValue);
             if (entity != null)
             {
                 var entities     = context.Entry(entity).Collection(x => x.GatherTrends).Query().OrderByDescending(a => a.Number).ToList();
                 var firstElement = entities.First();
                 var lastElement  = entities.Last();
                 var avgValue     = Math.Round(entities.Average(a => a.Number.Value));
                 this.txtLowExponent.Value    = lastElement.Number.ToString();
                 this.txtHeightExponent.Value = firstElement.Number.ToString();
                 this.txtAvgExponent.Value    = avgValue.ToString();
                 var startMonth = lastElement.Name.ToDateTime().Month;
                 this.txtStartMonth.Value = startMonth.ToString();
                 var startDay = lastElement.Name.ToDateTime().Day;
                 this.txtStartdDay.Value = startDay.ToString();
                 this.txtLowNumber.Value = lastElement.Number.Value.ToString();
                 var endMonth = firstElement.Name.ToDateTime().Month;
                 this.txtEndMonth.Value = endMonth.ToString();
                 var endDay = firstElement.Name.ToDateTime().Day;
                 this.txtEndDay.Value       = endDay.ToString();
                 this.txtHeightNumber.Value = firstElement.Number.Value.ToString();
                 if (avgValue <= 10)
                 {
                     this.ddlTrend.Value = "平稳";
                 }
                 else
                 {
                     this.ddlTrend.Value = "波动";
                 }
             }
         }
     }
     else
     {
         this.txtPath1.Text           = string.Empty;
         this.img_TrendChart.ImageUrl = null;
         this.pic_div1.Visible        = false;
         this.txtLowExponent.Value    = string.Empty;
         this.txtHeightExponent.Value = string.Empty;
         this.txtAvgExponent.Value    = string.Empty;
         this.txtStartMonth.Value     = string.Empty;
         this.txtStartdDay.Value      = string.Empty;
         this.txtLowNumber.Value      = string.Empty;
         this.txtEndMonth.Value       = string.Empty;
         this.txtEndDay.Value         = string.Empty;
         this.txtHeightNumber.Value   = string.Empty;
     }
 }
 public void Update(UserData item)
 {
     db.Entry(item).State = System.Data.Entity.EntityState.Modified;
 }
 public void Update(Point point)
 {
     db.Entry(point).State = EntityState.Modified;
 }