public async Task <IActionResult> AddOrRemove(StorageViewModel model)
        {
            try
            {
                if (model.ComponentId == Guid.Empty)
                {
                    throw new InvalidOperationException("Először válasszon ki egy terméket!");
                }

                if (model.IsAdd)
                {
                    await _storageService.AddAsync(model.ComponentId, model.Piece);
                }
                else
                {
                    await _storageService.RemoveAsync(model.ComponentId, model.Piece);
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch (InvalidOperationException e)
            {
                model.Errors = new List <string>()
                {
                    e.Message
                };
                return(RedirectToAction(nameof(Index), model));
            }
        }
Beispiel #2
0
        public async Task <PictureDTO> AddPicture(CreatePictureDTO data)
        {
            string fileName = GenerateRandomFileName(data.Extension);
            await _storageService.AddAsync(fileName, data.Picture);

            Picture picData = new Picture()
            {
                Date        = DateTime.UtcNow,
                Description = data.Description,
                PicIdentity = fileName,
                UserId      = _userService.GetUserId()
            };

            await _pictureRepository.AddAsync(picData);

            return(_mapper.Map <Picture, PictureDTO>(picData));
        }
Beispiel #3
0
        public async Task <IActionResult> Store(string id, IFormFile file)
        {
            try
            {
                if (CheckIfJsonFile(file))
                {
                    await _storageService.AddAsync(id, file);
                }
                else
                {
                    return(BadRequest(new
                    {
                        message = "Invalid file extension"
                    }));
                }
            }
            catch (Exception exp)
            {
                _logger.LogError(exp.StackTrace);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }

            return(Ok());
        }
Beispiel #4
0
        public async Task SetAsync(UserState data)
        {
            await _storageService.AddAsync(StorageKeyName, data).ConfigureAwait(false);

            _subject.OnNext(data);
        }
        public async Task SetAsync(AccountInformation data)
        {
            await _storageService.AddAsync(StorageKeyName, data).ConfigureAwait(false);

            _subject.OnNext(data);
        }
Beispiel #6
0
 public async Task WriteTokenAsync(SecurityToken token)
 {
     await _storageService.AddAsync <SecurityToken>(TABLE_STORAGE_IDENTIFIER, token);
 }
 public async Task <object> Add([FromBody] StorageModel model)
 {
     return(await _storageService.AddAsync(model));
 }