Esempio n. 1
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)));
            }
        }
        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));
            }
        }