Esempio n. 1
0
        public async Task UpdateDescription(CardDescriptionModel model)
        {
            var outpatientCard = await _context.OutpatientCards.FirstOrDefaultAsync(x => x.OutpatientCardId == model.CardId);

            if (outpatientCard == null)
            {
                throw new Exception($"Outpatient card not found. {model.CardId}");
            }
            outpatientCard.Description += "\n" + model.Description;

            if (!outpatientCard.DiseaseId.HasValue)
            {
                var diseaseResponse = await RequestExecutor.ExecuteRequestAsync(
                    MicroservicesEnum.Medical, RequestUrl.GetDiseaseIdByName,
                    new Parameter[] {
                    new Parameter("name", model.Disease, ParameterType.GetOrPost)
                });

                var diseaseResponseName = JsonConvert.DeserializeObject <MksResponse>(diseaseResponse);
                if (!diseaseResponseName.Success)
                {
                    throw new Exception("Disease not found");
                }
                outpatientCard.DiseaseId = JsonConvert.DeserializeObject <long>(diseaseResponseName.Data);
            }

            await _context.SaveChangesAsync();
        }
Esempio n. 2
0
        public async Task <IActionResult> UpdateDescription(CardDescriptionModel model)
        {
            var medicalResponse = JsonConvert.DeserializeObject <MksResponse>(
                await RequestExecutor.ExecuteRequestAsync(
                    MicroservicesEnum.Medical, RequestUrl.UpdateDescription, new Parameter[] {
                new Parameter("model", JsonConvert.SerializeObject(model), ParameterType.RequestBody)
            }));

            if (!medicalResponse.Success)
            {
                throw new Exception(medicalResponse.Data);
            }
            return(RedirectToAction("Index", "Outpatient"));
        }
Esempio n. 3
0
        public async Task <IActionResult> UpdateDescription([FromBody] CardDescriptionModel model)
        {
            try
            {
                await _outpatientRepository.UpdateDescription(model);

                return(Json(
                           new
                {
                    Success = true,
                    Data = "ok"
                }));
            }
            catch (Exception exception)
            {
                return(Json(new { Success = false, exception.Message }));
            }
        }