Exemple #1
0
        public async Task <ResultCode> AddAsync(DeviceModel device)
        {
            if (!await _ilnessStorage.ExistAsync(device.IlnessId))
            {
                return(ResultCode.NotFound);
            }
            if (await _deviceStorage.ExistAsync(device.Seria))
            {
                return(ResultCode.DeviceSeriaAlreadyExst);
            }
            var entity = _mapper.Map <DeviceModel, DeviceEntity>(device);
            await _deviceStorage.AddAsync(entity);

            return(ResultCode.Success);
        }
Exemple #2
0
        public async Task <ResultCode> AddIlnessAsync(int patientId, int ilnessId)
        {
            var patient = await _patientStorage.GetByPatientIdAsync(patientId);

            if (patient == null)
            {
                return(ResultCode.NotFound);
            }

            if (!await _ilnessStorage.ExistAsync(ilnessId))
            {
                return(ResultCode.NotFound);
            }

            if (await _patientStorage.HasIlnessAsync(patientId, ilnessId))
            {
                return(ResultCode.UserAlreadyHasIlness);
            }
            await _patientStorage.AddIlnessAsync(patientId, ilnessId);

            return(ResultCode.Success);
        }