public async Task <int> Add(string title, string contentParagraph, int position)
        {
            var theBinderyEvent = _theBinderyContentFactory.CreateEvent(title, contentParagraph, position);

            var eventToReplaceInPosition = _theBinderyContentRepository.GetEventByPosition(position);

            if (eventToReplaceInPosition != null)
            {
                eventToReplaceInPosition.Position = 0;
                _theBinderyContentRepository.Update(eventToReplaceInPosition);
            }

            _theBinderyContentRepository.Add(theBinderyEvent);

            await _theBinderyContentRepository.Context.CommitAsync();

            return(theBinderyEvent.Id);
        }
Ejemplo n.º 2
0
        public async Task <int> Add(string title, string contentParagraph, string author, int position)
        {
            var galleryImage = _theBinderyContentFactory.CreateGalleryImage(title, contentParagraph, author, position);

            var imageToReplaceInPosition = _theBinderyContentRepository.GetGalleryImageByPosition(position);

            if (imageToReplaceInPosition != null)
            {
                imageToReplaceInPosition.Position = 0;
                _theBinderyContentRepository.Update(imageToReplaceInPosition);
            }

            _theBinderyContentRepository.Add(galleryImage);

            await _theBinderyContentRepository.Context.CommitAsync();

            return(galleryImage.Id);
        }
Ejemplo n.º 3
0
        public async Task <int> Add(string title, string contentParagraph, DateTime?newsDate, string section, string author, int position)
        {
            var news = _theBinderyContentFactory.CreateNews(title, contentParagraph, newsDate, section, author, position);

            var newsToReplaceInPosition = _theBinderyContentRepository.GetNewsByPosition(position);

            if (newsToReplaceInPosition != null)
            {
                newsToReplaceInPosition.Position = 0;
                _theBinderyContentRepository.Update(newsToReplaceInPosition);
            }

            _theBinderyContentRepository.Add(news);


            await _theBinderyContentRepository.Context.CommitAsync();

            return(news.Id);
        }