/// <summary> /// Gets images by requested item id /// </summary> /// <param name="imagesList">List of images</param> /// <param name="requestedItemId">Id of requested item</param> private IEnumerable <RequestedItemImage> UploadImagesToStorage(IEnumerable <RequestedImageViewModel> imagesList, int requestedItemId) { Dictionary <RequestedItemImage, Task <string> > imageTastDictionary = new Dictionary <RequestedItemImage, Task <string> >(); foreach (var item in imagesList) { var newImage = new RequestedItemImage() { IsMain = item.IsMain, RequestedItemId = requestedItemId }; 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); }
/// <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> /// Update image in database /// </summary> /// <param name="item">Requested item image</param> /// <returns></returns> public RequestedItemImage Update(RequestedItemImage item) { throw new NotImplementedException(); }
/// <summary> /// Save image in database /// </summary> /// <param name="item">Requested item model</param> /// <returns>Requested item entity</returns> public RequestedItemImage Create(RequestedItemImage item) { var createdImage = this._context.RequestedItemImages.Add(item); return(createdImage.Entity); }