Ejemplo n.º 1
0
        public bool Add(AuthorBLL item, out string serverSideError)
        {
            if (item.IsValid)
            {
                using (ProtoLibEntities context = new ProtoLibEntities())
                {
                    if (DatabaseDependantValidation(item, context, out serverSideError))
                    {
                        Author newAuth = new Author();

                        //newAuth.BookDetailsSet = whoa... Okay, remember.. first authors are added, then new books and author specified there

                        CrossLayerEntityConverter.AuthorBllToDal(context, item, newAuth);
                        context.Authors.AddObject(newAuth);

                        context.SaveChanges();

                        return true;
                    }
                }

                return false;
            }
            else
            {
                serverSideError = "The Author object is invalid";
                return false;
            }
        }
        public static void AuthorBllToDal(ProtoLibEntities context, AuthorBLL bllAuthor, Author dalAuthor)
        {
            dalAuthor.FirstName = bllAuthor.FirstName;
            dalAuthor.MiddleName = bllAuthor.MiddleName;
            dalAuthor.LastName = bllAuthor.LastName;
            dalAuthor.DateOfBirth = bllAuthor.DateOfBirth;
            dalAuthor.DateOfDeath = bllAuthor.DateOfDeath;
            dalAuthor.Nationality = bllAuthor.Nationality;

            //FIXME: copy image binary data to BLL object
            dalAuthor.AuthorImage = bllAuthor.AuthorImage;

            foreach (int bookID in bllAuthor.BookDetailsIDs)
                dalAuthor.BookDetailsSet.Add(context.BookDetailsSet.Single(b => b.BookDetailsID == bookID));
        }
        public static void AuthorDalToBll(ProtoLibEntities context, AuthorBLL bllAuthor, Author dalAuthor)
        {
            bllAuthor.ItemID = dalAuthor.AuthorID;

            bllAuthor.FirstName = dalAuthor.FirstName;
            bllAuthor.MiddleName = dalAuthor.MiddleName;
            bllAuthor.LastName = dalAuthor.LastName;
            bllAuthor.DateOfBirth = dalAuthor.DateOfBirth;
            bllAuthor.DateOfDeath = dalAuthor.DateOfDeath;
            bllAuthor.Nationality = dalAuthor.Nationality;

            bllAuthor.AuthorImage = dalAuthor.AuthorImage;

            foreach (BookDetails b in dalAuthor.BookDetailsSet)
                bllAuthor.BookDetailsIDs.Add(b.BookDetailsID);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Create a new Author object.
 /// </summary>
 /// <param name="authorID">Initial value of the AuthorID property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 public static Author CreateAuthor(global::System.Int32 authorID, global::System.String firstName, global::System.String lastName)
 {
     Author author = new Author();
     author.AuthorID = authorID;
     author.FirstName = firstName;
     author.LastName = lastName;
     return author;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Authors EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAuthors(Author author)
 {
     base.AddObject("Authors", author);
 }