Ejemplo n.º 1
0
        public void SaveBook(BookDto editCandidate)
        {
            try
            {
                CheckOrAddSubEntities(editCandidate);

                Book dbEntry = null;
                if (editCandidate.Id != null)
                {
                    dbEntry = _entitiesContext.Books.Find(editCandidate.Id);
                }

                if (dbEntry != null)
                {
                    ConvertDtoBookToPocoBook(dbEntry, editCandidate);
                }
                else
                {
                    Book book = new Book();
                    ConvertDtoBookToPocoBook(book, editCandidate);
                    _entitiesContext.Books.Add(book);
                }

                _entitiesContext.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 2
0
        private void AddNewPublisher(string name)
        {
            var dedicatedContext = new GogolStoreEntities();

            var addedPublisher = dedicatedContext.Publishers.Add(new Publisher {
                Name = name, Country = "Ukraine"
            });                                                                                                      //TODO: Country hardcode - Temp

            dedicatedContext.SaveChanges();
        }