Beispiel #1
0
        public async Task <IActionResult> PostTbRTreatmentDetail([FromBody] TbRTreatmentDetail tbRTreatmentDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.TbRTreatmentDetail.Add(tbRTreatmentDetail);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (TbRTreatmentDetailExists(tbRTreatmentDetail.YearActive))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetTbRTreatmentDetail", new { id = tbRTreatmentDetail.YearActive }, tbRTreatmentDetail));
        }
Beispiel #2
0
        public async Task <IActionResult> DeleteTbRTreatmentDetail([FromBody] TbRTreatmentDetail controlDelete)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var tbRTreatmentDetail = await
                                     _context.TbRTreatmentDetail.SingleOrDefaultAsync(e => e.YearActive == controlDelete.YearActive && e.RiskNo == controlDelete.RiskNo && e.No == controlDelete.No);

            if (tbRTreatmentDetail == null)
            {
                return(NotFound());
            }

            _context.TbRTreatmentDetail.Remove(tbRTreatmentDetail);
            await _context.SaveChangesAsync();

            return(Ok(tbRTreatmentDetail));
        }
Beispiel #3
0
        public async Task <IActionResult> PutTbRTreatmentDetail([FromRoute] short id, [FromBody] TbRTreatmentDetail tbRTreatmentDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tbRTreatmentDetail.YearActive)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }