public async Task <IActionResult> PutRabbitStatistic([FromRoute] int id, [FromBody] RabbitStatistic rabbitStatistic)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != rabbitStatistic.ID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemple #2
0
        public async static Task <Weapon> Edit(Weapon w, StatContext context)
        {
            await context.AddAsync(w);

            context.Entry(w).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(w);
        }
Exemple #3
0
        public async static Task Delete(int id, StatContext context)
        {
            Weapon w = await GetWeaponById(id, context);

            if (w != null)
            {
                await context.AddAsync(w);

                context.Entry(w).State = EntityState.Deleted;
                await context.SaveChangesAsync();
            }
        }