Пример #1
0
        public async Task <IActionResult> PutCity(City city)
        {
            //if (id != city.CityId)
            //{
            //    return BadRequest();
            //}

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

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

            return(NoContent());
        }
Пример #2
0
        public async Task <IActionResult> PutCountry(int id, Country country)
        {
            if (id != country.CountryId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async static Task WriteDbContext(this CalcDbContext _db, int id, string message)
        {
            CalcResult calcResult = new CalcResult()
            {
                Insert_Date    = DateTimeOffset.UtcNow,
                Value          = message,
                CalcFunctionId = id
            };
            await _db.CalcResults.AddAsync(calcResult);

            await _db.SaveChangesAsync();
        }