예제 #1
0
 public void ClearPictures()
 {
     if (Pictures == null || Pictures.Any())
     {
         Pictures = new List <ProfilePicture>();
     }
 }
예제 #2
0
파일: Article.cs 프로젝트: lazyabp/cms
 public void AddPicture(Guid pictureId, string pictureUrl)
 {
     if (!Pictures.Any(x => x.PictureUrl == pictureUrl))
     {
         Pictures.Add(new ArticlePicture(pictureId, Id, pictureUrl));
     }
 }
예제 #3
0
        public virtual void AddMedia(Guid pictureId)
        {
            if (Pictures.Any(x => x.PictureId == pictureId))
            {
                Pictures.RemoveAll(x => x.PictureId == pictureId);
            }

            Pictures.Add(new ProductPicture(Id, pictureId));
        }
 public void AddPicture(string pictureUri, PictureSize size)
 => Apply(
     new V1.PictureAddedToAClassifiedAd
 {
     PictureId      = new Guid(),
     ClassifiedAdId = Id,
     OwnerId        = OwnerId,
     Url            = pictureUri,
     Height         = size.Height,
     Width          = size.Width,
     Order          = Pictures.Any() ? Pictures.Max(x => x.Order) : 0
 }
     );
예제 #5
0
        public void RemovePicture(Guid id)
        {
            if (Pictures == null || Pictures.Any())
            {
                throw SheaftException.NotFound("Cet utilisateur ne contient aucune images.");
            }

            var existingPicture = Pictures.FirstOrDefault(p => p.Id == id);

            if (existingPicture == null)
            {
                throw SheaftException.NotFound("L'image est introuvable.");
            }

            Pictures.Remove(existingPicture);
            PicturesCount = Pictures?.Count ?? 0;
        }
예제 #6
0
파일: Product.cs 프로젝트: sheaft-app/api
        public void AddPicture(ProductPicture picture)
        {
            if (Pictures == null)
            {
                Pictures = new List <ProductPicture>();
            }

            if (Pictures.Any(p => p.Position == picture.Position))
            {
                foreach (var productPicture in Pictures.Where(p => p.Position >= picture.Position))
                {
                    productPicture.IncreasePosition();
                }
            }

            Pictures.Add(picture);
            if (picture.Position == 0)
            {
                Picture = picture.Url;
            }

            PicturesCount = Pictures.Count;
        }