Пример #1
0
        public ActionResult EditOrCreate(int?id)
        {
            AuthorsDTO author = new AuthorsDTO();

            if (id != null)
            {
                author = authorService.GetAuthor(id);
            }
            return(View(author));
        }
Пример #2
0
        public void MakeAuthor(AuthorsDTO authorDto)
        {
            Authors author = new Authors
            {
                FirstName = authorDto.FirstName,
                LastName  = authorDto.LastName,
            };

            db.Authors.Create(author);
            db.Save();
        }
Пример #3
0
        public ActionResult EditOrCreate(Authors author)
        {
            if (author.Id != 0)
            {
                var tempAuthor = authorService.GetAuthor(author.Id);
                tempAuthor.FirstName = author.FirstName;
                tempAuthor.LastName  = author.LastName;
                authorService.SaveUpdate(author);
            }
            else
            {
                var authorDto = new AuthorsDTO {
                    LastName = author.LastName, FirstName = author.FirstName
                };
                authorService.MakeAuthor(authorDto);
            }

            return(RedirectToActionPermanent("Index", "Author"));
        }