Exemple #1
0
        public async Task <IActionResult> PutCup([FromRoute] string id, [FromRoute] string money)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Cup d = _context.Cups.Where(s => s.Id == id).First();

            int tmpmoney = Int32.Parse(d.limit);
            int newlimit = tmpmoney + Int32.Parse(money);

            d.limit = newlimit.ToString();


            Console.WriteLine(d);

            _context.Entry(d).State = EntityState.Modified;
            _context.SaveChanges();

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
            }

            return(NoContent());
        }
Exemple #2
0
        public async Task <IActionResult> PutUser([FromRoute] string id, [FromBody] User user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != user.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }