Example #1
0
        public IActionResult PostWithElectrocardiogram(int id, [FromForm] ElectrocardiogramView electrocardiogramView)
        {
            try
            {
                if (id == 0)
                {
                    return(BadRequest("id is zero"));
                }
                if (electrocardiogramView == null)
                {
                    return(BadRequest("Owner object is null"));
                }

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

                _medicalExaminationRepository.InsertElectrocardiogram(id, electrocardiogramView.ViewToEntity());

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, string.Format("Internal server error. Message error: {0}", ex.Message)));
            }
        }
Example #2
0
        public IActionResult PostElectrocardiogram([FromBody] ElectrocardiogramView electrocardiogram)
        {
            try
            {
                if (electrocardiogram == null)
                {
                    return(BadRequest("Owner object is null"));
                }

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

                electrocardiogram.Id = 0;
                _electrocardiogramRepository.Insert(electrocardiogram.ViewToEntity());

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