Exemplo n.º 1
0
        public bool Add(AdCreateModel entity)
        {
            #region Pictures Manipulation
            List <AdDetailPicture> pictures = new List <AdDetailPicture>();
            if (entity.FilesAsListOfByteArray != null && entity.FilesAsListOfByteArray.Count > 0)
            {
                foreach (var file in entity.FilesAsListOfByteArray)
                {
                    pictures.Add(new AdDetailPicture
                    {
                        File       = file,
                        CreatedBy  = entity.CreatedBy,
                        CreatedAt  = entity.CreatedAt,
                        ModifiedAt = entity.ModifiedAt,
                        ModifiedBy = entity.ModifiedBy,
                    });
                }

                entity.MainPictureThumbnail = MagiskImageWrapper.MakeThumbnailImage(System.Convert.FromBase64String(entity.MainPictureFile));
            }
            #endregion

            var ad = AdMapper.MapAdFromAdCreateModel(entity, pictures);

            return(_repository.Add(ad));
        }
Exemplo n.º 2
0
        public bool Update(AdEditModel entity)
        {
            Ad ad = _repository.GetAdWithDetails(entity.ID);

            if (ad == null)
            {
                throw new Exception(LOCALIZATION_GENERAL_NOT_FOUND + entity.ID);
            }

            if (entity.AdDetail != null && entity.AdDetail.AdDetailPictures != null)
            {
                foreach (var adDetailMap in entity.AdDetail.AdDetailPictures)
                {
                    ad.AdDetail.AdDetailPictures.Remove(adDetailMap);
                }
            }

            entity.MainPictureThumbnail = MagiskImageWrapper.MakeThumbnailImage(System.Convert.FromBase64String(entity.MainPictureFile));
            ad = AdMapper.MapAdFromAdEditModel(entity, ad);

            return(_repository.Update(ad));
        }