Beispiel #1
0
        private void RemoveExistingSerieItems(Serie serie)
        {
            // Remove files from disk
            var removedItems = serie.SerieItems.Where(i => !SerieItems.Any(si => i.FileName == si.Filename));

            // Remove from database
            if (removedItems.Any())
            {
                _context.SerieItems.RemoveRange(removedItems);
                _context.SaveChanges();
            }
        }
Beispiel #2
0
        public void Handle(EditProjectCommand command)
        {
            var project = _context.Projects.First(p => p.Id == command.ProjectId);

            project.Name            = command.Name;
            project.PublicationDate = command.PublicationDate;

            _context.SaveChanges();
        }
Beispiel #3
0
        public void Handle()
        {
            var project = new Project
            {
                Name            = Name,
                UniqueName      = Name.ReplaceSpaces(),
                PublicationDate = PublicationDate,
                Rank            = 0,
            };

            _context.Projects.Add(project);
            _context.SaveChanges();
        }
        public void Handle()
        {
            var rankCounter = 0;

            foreach (var projectId in ProjectIds)
            {
                var project = _context.Projects.First(p => p.Id == projectId);

                project.Rank = rankCounter;

                rankCounter++;
            }

            _context.SaveChanges();
        }
        private Serie CreateSerie(int?projectId)
        {
            var serie = new Serie
            {
                Created    = DateTime.Now,
                Name       = SerieName,
                UniqueName = SerieName.ReplaceSpaces(),
                Published  = PublicationDate,
                ProjectId  = projectId
            };

            _context.Series.Add(serie);
            _context.SaveChanges();

            return(serie);
        }
        private Project CreateProject()
        {
            if (ProjectName.HasValue())
            {
                var project = new Project
                {
                    Name = ProjectName,
                };

                _context.Projects.Add(project);
                _context.SaveChanges();

                return(project);
            }

            return(null);
        }
Beispiel #7
0
 public void SaveChanges()
 {
     try {
         _context.SaveChanges();
     } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) {
         Exception raise = dbEx;
         foreach (var validationErrors in dbEx.EntityValidationErrors)
         {
             foreach (var validationError in validationErrors.ValidationErrors)
             {
                 string message = string.Format("{0}:{1}",
                                                validationErrors.Entry.Entity.ToString(),
                                                validationError.ErrorMessage);
                 raise = new InvalidOperationException(message, raise);
             }
         }
         throw raise;
     }
 }
Beispiel #8
0
 public void Save()
 {
     db.SaveChanges();
 }