private void TrySavePresentation(Presentation createdPresentation) { using (IRepository repo = ApplicationSettings.GetRepository()) { repo.CreatePresentation(createdPresentation); repo.SaveChanges(); } }
private void CopyPresentationProperties(Presentation fromPresentation, Presentation toPresentation) { if(fromPresentation == null) { throw new ArgumentNullException("fromPresentation"); } if(toPresentation == null) { throw new ArgumentNullException("toPresentation"); } toPresentation.CreateDate = fromPresentation.CreateDate; toPresentation.Description = fromPresentation.Description; toPresentation.Name = fromPresentation.Name; toPresentation.SlidesJSON = fromPresentation.SlidesJSON; toPresentation.Tags = fromPresentation.Tags; }
public void DeletePresentation(Presentation presentation) { if(presentation == null) { throw new ArgumentNullException("presentation"); } var existPresentation = _dbContext.Presentations.FirstOrDefault(x => x.PresentationId == presentation.PresentationId); if(existPresentation == null) { throw new InvalidDataException("this presentation doesn't exist in current data base"); } _dbContext.Presentations.Remove(existPresentation); }
public void UpdatePresentation(Presentation presentation) { if(presentation == null) { throw new ArgumentNullException("presentation"); } var existPresentation = _dbContext.Presentations.FirstOrDefault(x => x.PresentationId == presentation.PresentationId); if(existPresentation == null) { throw new InvalidDataException("This presentation doesn't exist in the current data base"); } if (presentation != existPresentation) { CopyPresentationProperties(presentation, existPresentation); } _dbContext.Entry(existPresentation).State = EntityState.Modified; }
public void CreatePresentation(Presentation presentation) { if(presentation == null) { throw new ArgumentNullException("presentation"); } _dbContext.Presentations.Add(presentation); }