Пример #1
0
        public Author Add(AuthorToAddOrUpdate authorToAddOrUpdate)
        {
            var author = new Author(
                authors.GetNextId(),
                authorToAddOrUpdate.Name,
                authorToAddOrUpdate.Email);

            authors.Add(author.Id, author);

            return(author);
        }
Пример #2
0
        public Author Update(int id, AuthorToAddOrUpdate authorToAddOrUpdate)
        {
            if (!authors.ContainsKey(id))
            {
                return(null);
            }

            var updatedAuthor = new Author(
                id,
                authorToAddOrUpdate.Name,
                authorToAddOrUpdate.Email);

            authors[id] = updatedAuthor;

            return(updatedAuthor);
        }