Guest User

Untitled

a guest
Nov 21st, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. .then((item, attachments) => {
  2. let promises = [];
  3. attachments.forEach(attachment => {
  4. promises.push(addItem(item, attachment));
  5. });
  6. return Promise.all(promises.map(promise => { promise.catch(e => console.log(e)); }));
  7. })
  8. .then(() => { return getIems(); })
  9. .then(items => $scope.items = items);
  10.  
  11. function addItem(item, attachment){
  12. let url = '';
  13. return Upload.upload({
  14. url: url,
  15. data: {attachment: attachment, model: Upload.json(item) }
  16. });
  17. }
  18.  
  19. public async Task<IHttpActionResult> AddItem()
  20. {
  21. try
  22. {
  23. //Здесь логика проверки и сохранения файла
  24. return Ok();
  25. }
  26. catch
  27. {
  28. return BadRequest
  29. }
  30. }
  31.  
  32. .then((item, attachments) => {
  33. let promises = attachments.map(attachment => {
  34. return addItem(item, attachment));
  35. });
  36. return $q.all(promises);
  37. })
  38. .then(() => {
  39. $scope.items = getIems()
  40. })
  41. .catch(console.error);
Add Comment
Please, Sign In to add comment