public IHttpActionResult PutServer(int id, Server server) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != server.Id) { return(BadRequest()); } db.Entry(server).State = System.Data.Entity.EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ServerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void Crunch(ptOSContainer context, object obj) { var now = DateTime.UtcNow; var stat = context.Statistics.FirstOrDefault(x => x.Type == Name); if (stat == null) { stat = context.Statistics.Add(new Statistic { Type = Name, At = now, }); } var hourAgo = now.AddHours(-1); stat.Value = context.Events.Count(x => x.Submitted > hourAgo); context.SaveChanges(); }