Пример #1
0
        public ActionResult <RemoveFileResourceModel> RemoveFile([FromRoute][FromQuery] RemoveFileInputModel inputModel)
        {
            try
            {
                return(this.memoryCacheFileSevice.RemoveFile <RemoveFileResourceModel>(inputModel));
            }
            catch (Exception ex)
            {
                this.loggerService.LogException(ex);

                return(this.BadRequest());
            }
        }
        public TModel RemoveFile <TModel>(RemoveFileInputModel inputModel)
        {
            var formSessionIdAsString = inputModel.FormSessionId.ToString();

            var key = this.cacheManager.GetKeys().Where(x => x == formSessionIdAsString).SingleOrDefault();

            if (this.cacheManager.IsSet(formSessionIdAsString))
            {
                var formSessionStorage = this.cacheManager.Get <List <UploadFileUtilityModel> >(key, null);

                var file = formSessionStorage.SingleOrDefault(x => x.FileGuid == inputModel.Id);

                formSessionStorage.Remove(file);

                return(file.To <TModel>());
            }

            throw new NullReferenceException(NullReferenceExceptionsConstants.FormSessionKeyNotFound);
        }