Ejemplo n.º 1
0
        public async Task <IActionResult> AddEditAppointmentDetail(int id, [FromBody] HospitalAppointmentDetailModel param)
        {
            if (ModelState.IsValid)
            {
                var result = await _appointmentService.AddEditAppointmentDetailAsync(id, param);

                if (result.Success)
                {
                    return(Ok(result.Item));
                }
                else
                {
                    return(BadRequest(result.Message));
                }
            }
            else
            {
                return(BadRequest(MessageConstant.ValidationError));
            }
        }
Ejemplo n.º 2
0
        public async Task <Response <HospitalAppointmentDetailModel> > AddEditAppointmentDetailAsync(int id, HospitalAppointmentDetailModel appointmentDetail)
        {
            var response = InitErrorResponse <HospitalAppointmentDetailModel>();

            var en = await _unitOfWork.HospitalAppointmentRepository.GetSingleAsync(id);

            var userId = GetUserId();

            if (userId == en.CreatedById)
            {
                string message;
                var    entity = Mapper.Map <HospitalAppointmentDetail>(appointmentDetail);
                entity.HospitalAppointment = null;
                entity.Patient             = null;
                if (entity.Id == 0)
                {
                    _unitOfWork.HospitalAppointmentDetailRepository.Add(entity);
                    message = MessageConstant.Create;
                }
                else
                {
                    _unitOfWork.HospitalAppointmentDetailRepository.Edit(entity);
                    message = MessageConstant.Update;
                }

                _unitOfWork.Commit();

                response = InitSuccessResponse <HospitalAppointmentDetailModel>(message);
            }
            else
            {
                response.Message = MessageConstant.UserNotAllowed;
            }



            return(response);
        }