コード例 #1
0
ファイル: TariffService.cs プロジェクト: AbinJames/Tariff
        //function to edit invoice details
        public void EditInvoice(int id, InvoiceMaster invoiceMaster)
        {
            tariffContext.Entry(invoiceMaster).State = EntityState.Modified;

            try
            {
                tariffContext.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
コード例 #2
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());
        }
コード例 #3
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);
        }