コード例 #1
0
        public IActionResult PutHeartUltrasound([FromBody] HeartUltrasoundView heartUltrasound)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Invalid data."));
                }

                var elem = _heartUltrasoundRepository.GetBy(t => t.Id == heartUltrasound.Id);

                if (elem != null)
                {
                    elem.Info = heartUltrasound.Info;

                    _heartUltrasoundRepository.Update(elem);

                    return(Ok());
                }

                return(NotFound());
            }
            catch
            {
                return(BadRequest());
            }
        }
コード例 #2
0
        public IActionResult PostWithHeartUltrasound(int id, [FromForm] HeartUltrasoundView heartUltrasoundView)
        {
            try
            {
                if (id == 0)
                {
                    return(BadRequest("id is zero"));
                }
                if (heartUltrasoundView == null)
                {
                    return(BadRequest("Owner object is null"));
                }

                if (!ModelState.IsValid)
                {
                    return(BadRequest("Invalid model object"));
                }

                _medicalExaminationRepository.InsertHeartUltrasound(id, heartUltrasoundView.ViewToEntity());

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, string.Format("Internal server error. Message error: {0}", ex.Message)));
            }
        }
コード例 #3
0
        public static HeartUltrasound ViewToEntity(this HeartUltrasoundView view)
        {
            if (view != null)
            {
                return(new HeartUltrasound
                {
                    Id = view.Id,
                    Info = view.Info,
                    MedicalExaminationId = view.MedicalExaminationId
                });
            }

            return(null);
        }
コード例 #4
0
        public IActionResult PostHeartUltrasound([FromBody] HeartUltrasoundView heartUltrasound)
        {
            try
            {
                if (heartUltrasound == null)
                {
                    return(BadRequest("Owner object is null"));
                }

                if (!ModelState.IsValid)
                {
                    return(BadRequest("Invalid model object"));
                }

                heartUltrasound.Id = 0;
                _heartUltrasoundRepository.Insert(heartUltrasound.ViewToEntity());

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, "Internal server error" + ex.Message));
            }
        }