Esempio n. 1
0
        public async Task <IActionResult> PutTbmCompany(int id, TbmCompany tbmCompany)
        {
            if (id != tbmCompany.CompanyId)
            {
                return(BadRequest());
            }

            if (TbmCompanyExists(tbmCompany.CompanyCode))
            {
                return(Conflict());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TbmCompanyExists(tbmCompany.CompanyCode))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <ActionResult <TbmCompany> > PostTbmCompany(TbmCompany tbmCompany)
        {
            if (TbmCompanyExists(tbmCompany.CompanyCode))
            {
                return(Conflict());
            }


            _context.TbmCompanies.Add(tbmCompany);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTbmCompany", new { id = tbmCompany.CompanyId }, tbmCompany));
        }