Пример #1
0
        public async Task <IActionResult> PostWithInjuriesDiseases(int id, [FromForm] InjuriesDiseasesView injuriesDiseasesView)
        {
            try
            {
                if (id == 0)
                {
                    return(BadRequest("id is zero"));
                }
                if (injuriesDiseasesView == null)
                {
                    return(BadRequest("Owner object is null"));
                }

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

                await _uploadFileAndSavePath.UloadFile(injuriesDiseasesView);

                _patientRepository.InsertInjuriesDiseases(id, injuriesDiseasesView.ViewToEntity());

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(500, string.Format("Internal server error. Message error: {0}", ex.Message)));
            }
        }
        public async Task <IActionResult> Put([FromForm] InjuriesDiseasesView injuriesDiseasesView)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Invalid data."));
                }

                await _uploadFileAndSavePath.UloadFile(injuriesDiseasesView);

                if (_injuriesDiseasesRepository.UpdateFull(injuriesDiseasesView.ViewToEntity()))
                {
                    return(Ok());
                }

                return(NotFound());
            }
            catch
            {
                return(BadRequest());
            }
        }