public IActionResult AddMedicalHistory([FromBody] MedicalHistoryDto medicalHistoryDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Pet pet = _repoWrapper.Pet.FindByCondition(p => p.Id == medicalHistoryDto.PetId).FirstOrDefault();

            if (pet == null)
            {
                return(BadRequest("PetId is incorrect"));
            }

            var            config         = new MapperConfiguration(cfg => cfg.CreateMap <MedicalHistoryDto, MedicalHistory>());
            var            mapper         = new Mapper(config);
            MedicalHistory medicalHistory = mapper.Map <MedicalHistoryDto, MedicalHistory>(medicalHistoryDto);

            if (medicalHistory.EndDate == null)
            {
                pet.IsSick = true;
                _repoWrapper.Pet.Update(pet);
            }

            _repoWrapper.MedicalHistory.Create(medicalHistory);
            _repoWrapper.Save();

            return(Ok(new { Success = true }));
        }
예제 #2
0
 public IActionResult Put([FromRoute] int id, [FromBody] MedicalHistoryDto medicalHistory)
 {
     return(new JsonVoidResult
     {
         Errors = null,
         StatusCode = HttpStatusCode.OK,
         Message = null
     });
 }
예제 #3
0
        public async Task <IActionResult> CreateMedicalHistoryAsync([FromBody] MedicalHistoryDto medicalHistory)
        {
            JsonResult <int> result = await ExecuteActionWithResultAsync(async() =>
                                                                         await _medicalHistoryManager.CreateMedicalHistoryAsync(medicalHistory)) as JsonResult <int>;

            result.Message    = string.Format(Messages.Information_CreateSuccess_Template, Messages.Entity_MedicalHistory);
            result.StatusCode = HttpStatusCode.Created;

            return(result);
        }
예제 #4
0
        /// <inheritdoc />
        public async Task <int> CreateMedicalHistoryAsync(MedicalHistoryDto medicalHistory)
        {
            var domainMedicalHistory = await _medicalHistoryRepository.AddAndSaveAsync(Mapper.Map <MedicalHistory>(medicalHistory));

            return(domainMedicalHistory.Id);
        }