Example #1
0
        public async Task <IActionResult> PutTagv2(int id, Tag tag)
        {
            if (id != tag.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("Id,TradeName,ManufactureCompany,AdditionalInfo,TestCertificateIssuer,TestReportNumber,TestCertificateNumber,SupplierCommercialRegistry,SupplierName")] Trade trade)
        {
            if (ModelState.IsValid)
            {
                _context.Add(trade);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
                return(RedirectToAction("Details", new { id = trade.Id }));
            }
            return(View(trade));
        }
        public async Task AddAsync(ValueMaps vm)
        {
            IDbContextTransaction tx = null;

            try
            {
                using (tx = await context.Database.BeginTransactionAsync())
                {
                    context.ValueMaps.Add(vm);
                    await context.SaveChangesAsync();

                    tx.Commit();
                }
            }
            catch (DbUpdateException ex)
            {
                tx.Rollback();
            }
        }