Exemple #1
0
        /// <summary>
        /// Sets specified images of specified offer item
        /// </summary>
        /// <param name="model">Offer item view model</param>
        /// <param name="item">Offered item entity</param>
        /// <returns>List of offered item images</returns>
        public OfferedItemImageViewModel[] SetNewPictures(OfferedItemViewModel model, OfferedItem item)
        {
            int i = 0;
            Dictionary <OfferedItemImage, Task <string> > d = new Dictionary <OfferedItemImage, Task <string> >();

            foreach (var thing in model.Image)
            {
                var newImage = new OfferedItemImage
                {
                    IsMain        = thing.IsMain,
                    OfferedItemId = item.Id
                };
                var t = _imgService.UploadImage(Convert.FromBase64String(model.Base64Images[i++]));

                d.Add(newImage, t);
            }
            Task.WhenAll(d.Values);

            foreach (var element in d)
            {
                element.Key.ImageUrl = element.Value.Result;
            }

            this._unitOfWork.OfferImagesRepository.CreateMany(d.Keys.ToList());
            return(model.Image);
        }
Exemple #2
0
        public void Delete(int id)
        {
            OfferedItemImage offeredItemImage = _context.OfferedItemImages.FirstOrDefault(a => a.Id == id);

            if (offeredItemImage != null)
            {
                _context.OfferedItemImages.Remove(offeredItemImage);
            }
        }
 /// <summary>
 /// Convert OfferedItemImage To OfferedItemImageViewModel
 /// </summary>
 /// <param name="offeredItemImages"></param>
 /// <returns></returns>
 private OfferedItemImageViewModel ConvertOfferedItemImageToViewModel(OfferedItemImage offeredItemImages)
 {
     return(new OfferedItemImageViewModel()
     {
         Id = offeredItemImages.Id,
         IsMain = offeredItemImages.IsMain,
         OfferedItemId = offeredItemImages.OfferedItemId,
         ImageUrl = AzureStorageConfiguration.GetImageUrl(offeredItemImages.ImageUrl)
     });
 }
Exemple #4
0
 /// <summary>
 /// Configures model creation
 /// </summary>
 /// <param name="modelBuilder">modelBuilder to configure Model Creation</param>
 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     User.Configure(modelBuilder);
     Phone.Configure(modelBuilder);
     Address.Configure(modelBuilder);
     UserAddress.Configure(modelBuilder);
     Role.Configure(modelBuilder);
     Organization.Configure(modelBuilder);
     OrgAddress.Configure(modelBuilder);
     ExternalContact.Configure(modelBuilder);
     Membership.Configure(modelBuilder);
     Currency.Configure(modelBuilder);
     BankAccount.Configure(modelBuilder);
     OrgAccount.Configure(modelBuilder);
     Balance.Configure(modelBuilder);
     Target.Configure(modelBuilder);
     FinOp.Configure(modelBuilder);
     Tag.Configure(modelBuilder);
     TagFinOp.Configure(modelBuilder);
     Event.Configure(modelBuilder);
     EventImage.Configure(modelBuilder);
     Complaint.Configure(modelBuilder);
     GoodsType.Configure(modelBuilder);
     GoodsCategory.Configure(modelBuilder);
     OfferedItem.Configure(modelBuilder);
     RequestedItem.Configure(modelBuilder);
     BankImport.Configure(modelBuilder);
     BankImportDetail.Configure(modelBuilder);
     PasswordReset.Configure(modelBuilder);
     BannedUser.Configure(modelBuilder);
     BannedOrganization.Configure(modelBuilder);
     SubscribeOrganization.Configure(modelBuilder);
     Status.Configure(modelBuilder);
     OfferedItemImage.Configure(modelBuilder);
     RequestedItemImage.Configure(modelBuilder);
     UserResponse.Configure(modelBuilder);
     OrganizationResponse.Configure(modelBuilder);
     Donation.Configure(modelBuilder);
     Bank.Configure(modelBuilder);
     AutoImportIntervals.Configure(modelBuilder);
 }
        /// <summary>
        ///  Sets specified images of specified offer item. First image is Main
        /// </summary>
        /// <param name="images">Base64 code of images</param>
        /// <param name="offeredItemId">Offered item Id</param>
        /// <returns>Collection of offered item images</returns>
        public ICollection <OfferedItemImage> UploadImagesToStorage(IEnumerable <OfferedItemImageViewModel> images, int offeredItemId)
        {
            Dictionary <OfferedItemImage, Task <string> > imageTastDictionary = new Dictionary <OfferedItemImage, Task <string> >();

            foreach (var item in images)
            {
                var newImage = new OfferedItemImage()
                {
                    IsMain        = item.IsMain,
                    OfferedItemId = offeredItemId
                };

                var t = _imgService.UploadImageAsync(Convert.FromBase64String(item.Base64Data), item.ImageExtension);
                imageTastDictionary.Add(newImage, t);
            }
            Task.WhenAll(imageTastDictionary.Values);

            foreach (var element in imageTastDictionary)
            {
                element.Key.ImageUrl = element.Value.Result;
            }

            return(imageTastDictionary.Keys);
        }
Exemple #6
0
 public OfferedItemImage Update(OfferedItemImage item)
 {
     throw new NotImplementedException();
 }
Exemple #7
0
 public OfferedItemImage Create(OfferedItemImage item)
 {
     this._context.Add(item);
     return(item);
 }