Exemple #1
0
        public async Task <IActionResult> PutChangeCurrency([FromRoute] int id, [FromBody] ChangeCurrency changeCurrency)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
Exemple #2
0
        public async Task <IActionResult> PostChangeCurrency([FromBody] ChangeCurrency changeCurrency)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ChangeCurrency.Add(changeCurrency);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetChangeCurrency", new { id = changeCurrency.Id }, changeCurrency));
        }