Exemplo n.º 1
0
        public Author Save(Author author)
        {
            using (var context = new DataContext())
            {
                if (author.Id == 0)
                {
                    context.Authors.Add(author);
                }
                else
                {
                    context.Entry(author).State = EntityState.Modified;
                    context.Authors.AddOrUpdate(author);
                }
                context.SaveChanges();

            }
            return author;
        }