예제 #1
0
        public async Task <IActionResult> PutTariff(string id, Tariff tariff)
        {
            if (id != tariff.ServiceName)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #2
0
        public async Task <bool> InsertAsync(Models.Tariff tariffNew)
        {
            var tariffOld = await GetCurrencTariffValueAsync(tariffNew.CompanyName, tariffNew.CategoryId);

            if (tariffOld != null)
            {
                tariffOld.ExpirationDate        = DateTime.UtcNow;
                _context.Entry(tariffOld).State = EntityState.Modified;
                await _context.SaveChangesAsync();
            }

            await _context.Tariffs.AddAsync(tariffNew);

            var inserted = await _context.SaveChangesAsync();

            return(inserted > 0 ? true : false);
        }