Esempio n. 1
0
        public async Task <IActionResult> PostTbMRiskMapping([FromBody] TbMRiskMapping tbMRiskMapping)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.TbMRiskMapping.Add(tbMRiskMapping);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (TbMRiskMappingExists(tbMRiskMapping.YearActive))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetTbMRiskMapping", new { id = tbMRiskMapping.YearActive }, tbMRiskMapping));
        }
Esempio n. 2
0
        public async Task <IActionResult> PutTbMRiskMapping([FromRoute] short id, [FromBody] TbMRiskMapping tbMRiskMapping)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }



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

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

            return(NoContent());
        }