Пример #1
0
        public void IsValid()
        {
            var item = new BmiDto()
            {
                Height = 300,
                Weight = 500,
            };

            Assert.IsTrue(item.IsValid());
        }
Пример #2
0
        /// <summary>
        /// Removes the specified BMI entry from the specified patient.
        /// </summary>
        /// <param name="forPatient">The patient.</param>
        /// <param name="dto">The dto to remove.</param>
        public void Remove(BmiDto bmi, LightPatientDto forPatient)
        {
            var ebmi = this.Session.Get <Bmi>(bmi.Id);

            this.Session.Delete(ebmi);

            var patient = this.Session.Get <Patient>(forPatient.Id);

            this.Session.Update(patient);
        }
Пример #3
0
        public void IsInvalid_TooTiny()
        {
            var item = new BmiDto()
            {
                Height = 1,
                Weight = 150,
            };

            Assert.IsFalse(item.IsValid());
        }
Пример #4
0
        public void IsInvalid_TooLight()
        {
            var item = new BmiDto()
            {
                Weight = 0.999F,
                Height = 150,
            };

            Assert.IsFalse(item.IsValid());
        }
Пример #5
0
        public void IsInvalid_TooHeavy()
        {
            var item = new BmiDto()
            {
                Weight = 501,
                Height = 150,
            };

            Assert.IsFalse(item.IsValid());
        }
Пример #6
0
        /// <summary>
        /// Adds a bmi entry to the specified patient.
        /// </summary>
        /// <param name="bmi">The bmi.</param>
        /// <param name="forPatient">The patient.</param>
        public void Create(BmiDto bmi, LightPatientDto forPatient)
        {
            var entity = this.Session.Get <Patient>(forPatient.Id);

            if (entity != null)
            {
                entity.Height = bmi.Height;
                entity.BmiHistory.Add(Mapper.Map <BmiDto, Bmi>(bmi));
                this.Session.Update(entity);

                forPatient.Height = bmi.Height;
            }
            else
            {
                throw new EntityNotFoundException(typeof(Bmi));
            }
        }
Пример #7
0
        private void AddBmi()
        {
            Assert.IsNotNull(PluginContext.Host, "PluginContext.Host");
            Assert.IsNotNull(PluginContext.Host.SelectedPatient, "SelectedPatient");
            Assert.IsNotNull(this.CurrentBmi, "CurrentBmi");

            try
            {
                this.component.CreateBmi(this.CurrentBmi, PluginContext.Host.SelectedPatient);
                PluginContext.Host.WriteStatus(StatusType.Info, Messages.Msg_BmiAdded);
                this.CurrentBmi = new BmiDto();
            }
            catch (Exception ex)
            {
                this.Handle.Error(ex, Messages.Msg_ErrAddBmi);
            }
            this.Close();
        }
Пример #8
0
 /// <summary>
 /// Adds a bmi entry to the specified patient.
 /// </summary>
 /// <param name="bmi">The bmi.</param>
 /// <param name="patient">The patient.</param>
 public void CreateBmi(BmiDto bmi, LightPatientDto patient)
 {
     new Creator(this.Session).Create(bmi, patient);
 }
Пример #9
0
 /// <summary>
 /// Removes the specified BMI entry from the specified patient.
 /// </summary>
 /// <param name="from">The patient.</param>
 /// <param name="dto">The dto to remove.</param>
 public void Remove(BmiDto bmi, LightPatientDto from)
 {
     new Remover(this.Session).Remove(bmi, from);
 }