public ActionResult <IEnumerable <RemoveAllFilesForSessionResourceModel> > RemoveAllFilesForSession( [FromQuery] RemoveAllFilesForSessionInputModel inputModel) { try { return(this.memoryCacheFileSevice.RemoveAllFilesForSession <RemoveAllFilesForSessionResourceModel>( inputModel)); } catch (Exception ex) { this.loggerService.LogException(ex); return(this.BadRequest()); } }
public List <TModel> RemoveAllFilesForSession <TModel>(RemoveAllFilesForSessionInputModel inputModel) { var formSessionIdAsString = inputModel.FormSessionId.ToString(); var key = this.cacheManager.GetKeys().Where(x => x == formSessionIdAsString).SingleOrDefault(); var deletedFormSessionCacheCopy = new List <TModel>(); if (this.cacheManager.IsSet(formSessionIdAsString)) { var formSessionStorage = this.cacheManager.Get <List <UploadFileUtilityModel> >(key, null); deletedFormSessionCacheCopy.AddRange(formSessionStorage.Select(uf => uf.To <TModel>())); formSessionStorage.Clear(); this.cacheManager.Remove(formSessionIdAsString); return(deletedFormSessionCacheCopy); } throw new NullReferenceException(NullReferenceExceptionsConstants.FormSessionKeyNotFound); }