public async Task <ActionResult> Index(IEnumerable <IFormFile> contents) { var pictureNames = new List <string>(); foreach (var item in contents) { var fileName = $"{Guid.NewGuid().ToString()}{Path.GetExtension(item.FileName)}"; await _blobStorageRepository.UploadAsync(item.OpenReadStream(), fileName, ContainerType.picture); pictureNames.Add(fileName); } var user = await _tableStorageRepository.GetAsync(City, UserId); if (user != null) { var picture = JsonConvert.DeserializeObject <List <string> >(user.RawPaths); pictureNames.AddRange(picture); user.RawPaths = JsonConvert.SerializeObject(pictureNames); await _tableStorageRepository.AddAsync(user); } else { var newUser = new UserPicture { RowKey = UserId, PartitionKey = City, RawPaths = JsonConvert.SerializeObject(pictureNames) }; await _tableStorageRepository.AddAsync(newUser); } return(RedirectToAction("Index")); }
public async Task <ActionResult> Add(Customers customers) { //customers.Timestamp = DateTime.Now; customers.CustomerCode = Guid.NewGuid().ToString(); customers.RowKey = Guid.NewGuid().ToString(); customers.PartitionKey = "CustomerType"; var response = await _tableStorageRepository.AddAsync(customers); return(RedirectToAction("Index")); }