Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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();
        }