Esempio n. 1
0
        public void CreateNewNewsItem(NewsItemViewModel newsItemViewModel)
        {
            var dataTimeNow = DateTime.Now;
            var entity      = new NewsItem
            {
                Header         = newsItemViewModel.Header,
                Description    = newsItemViewModel.Description,
                AutorFio       = "Неавторизован",
                CreatedDate    = dataTimeNow,
                LastChangeDate = dataTimeNow,
                Category       = newsItemViewModel.CategoryId,
            };
            var collection = new List <Application.Dal.Domain.Files.File>();

            //uploadFiles
            foreach (var file in newsItemViewModel?.UploadedFiles)
            {
                collection.Add(_uploadService.InsertFile(file));
            }

            entity.Files = collection;
            _newsService.CreateNews(entity);
        }