예제 #1
0
        /// <summary>
        /// Creates the specified picture for the specified patient.
        /// </summary>
        /// <param name="picture">The picture.</param>
        /// <param name="patient">The patient.</param>
        public void Create(PictureDto picture, LightPatientDto forPatient)
        {
            Assert.IsNotNull(picture, "item");

            var foundPatient = (from p in this.Session.Query<Patient>()
                                where p.Id == forPatient.Id
                                select p).FirstOrDefault();
            if (foundPatient == null) throw new ExistingItemException();

            var newItem = Mapper.Map<PictureDto, Picture>(picture);
            newItem.Refresh(picture, this.Session);

            foundPatient.Pictures.Add(newItem);
            new ImageHelper().TryCreateThumbnail(foundPatient.Pictures);
            this.Session.Update(foundPatient);
        }
예제 #2
0
 /// <summary>
 /// Creates the specified picture for the specified patient.
 /// </summary>
 /// <param name="picture">The picture.</param>
 /// <param name="patient">The patient.</param>
 public void Create(PictureDto picture, LightPatientDto forPatient)
 {
     new Creator(this.Session).Create(picture, forPatient);
 }
예제 #3
0
 public static void Refresh(this Picture picture, PictureDto from, ISession session)
 {
     picture.Tag = session.Get<Tag>(from.Tag.Id) ?? picture.Tag;
 }
예제 #4
0
        /// <summary>
        /// Updates the specified picture.
        /// </summary>
        /// <param name="picture">The picture.</param>
        public void Update(PictureDto item)
        {
            var entity = this.Session.Get<Picture>(item.Id);
            if (entity == null) throw new EntityNotFoundException(typeof(Picture));

            Mapper.Map<PictureDto, Picture>(item, entity);

            entity.Tag = this.Session.Get<Tag>(item.Tag.Id);

            this.Session.Merge(entity);
        }