Esempio n. 1
0
        public async Task <List <Referat> > GetAllReferats()
        {
            using (var repository = new ReferatsRepository())
            {
                var referats = await repository.GetAllReferats();

                return(referats);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Check if downloaded referat is not already in DB and add it to DB
        /// </summary>
        /// <param name="referat">Downloaded referat</param>
        /// <returns></returns>
        public async Task AddReferatAsync(Referat referat)
        {
            using (var repository = new ReferatsRepository())
            {
                // Check if we have already download such a referat (COMPARE BY TOPIC)
                var referats = await repository.GetAllReferats();

                if (referats.Any(r => r.Topic.Equals(referat.Topic, StringComparison.CurrentCultureIgnoreCase)))
                {
                    return;
                }

                await repository.Insert(referat);
            }
        }