public AddEditBookElementViewModel(IService service, BookElement bookElement) : base(service) { BookElement = bookElement; isCreating = bookElement.Title == null; WindowTitle = !isCreating ? ("Editing '" + bookElement.Title + "'") : ("Adding new " + bookElement?.GetType().Name.ToLowerInvariant()); Title = bookElement?.Title ?? String.Empty; }
public void DeleteBookElement(Guid id) { BookElement bookElement = this.bookElementSetWrapper.GetById(id); if (bookElement != null) { this.bookElementSetWrapper.Delete(bookElement); this.SaveChanges(); } }
/// <summary> /// Method to spawn a book with randomized color and shape based on bookTemplate. /// Spawned books are randomly positioned based on the parent and added to the spawned books list. /// </summary> protected void RandomizeContentBook() { int colorNumb = Random.Range(0, colorsOfBook.Length); int shapeNumb = Random.Range(0, shapesOfBook.Length); GameObject tempBook; tempBook = Instantiate(bookTemplate, bookTemplate.transform.parent); tempBook.SetActive(true); tempBook.name = "Book" + (bookTemplate.transform.parent.transform.childCount - 2); books.Add(tempBook); BookElement element = tempBook.GetComponent <BookElement>(); Color r = Color.black; if (colorNumb == 0) { r = Color.red; element.color = "Merah"; } else if (colorNumb == 1) { r = Color.green; element.color = "Hijau"; } else if (colorNumb == 2) { r = Color.blue; element.color = "Biru"; } int i = 0; while (i < shapesOfBook.Length) { if (i == shapeNumb) { element.shape = shapesOfBook[shapeNumb].name; } i++; } element.inRecord = false; element.inArea = true; tempBook.transform.GetComponent <MeshRenderer>().materials[0].color = r; tempBook.transform.GetChild(0).GetComponent <SpriteRenderer>().sprite = shapesOfBook[shapeNumb]; float ex = tempBook.transform.position.x; float ez = tempBook.transform.position.z; tempBook.transform.position = new Vector3(ex + Random.Range(-0.09f, 0.07f), bookTemplate.transform.position.y, ez + Random.Range(-0.195f, 0.195f)); }
public IActionResult Index() { //Create a new list of books named 'BookList' IList <Book> BookList = new List <Book>(); //Create a new XML Document named 'xdoc' XmlDocument xdoc = new XmlDocument(); //Create a string with the value of the path to the XML file string path = Request.PathBase + "XML/books.xml"; //If the path exists, do the following if (System.IO.File.Exists(path)) { //Load the XML document xdoc.Load(path); //Create a new list of XML nodes equal to the XML Element "book" XmlNodeList Books = xdoc.GetElementsByTagName("book"); //For every book in the root element "books" (inside of the XML document) foreach (XmlElement BookElement in Books) { //Instantiate a new Book object named NewBook Book NewBook = new Book { //An Id member, equal to the first 'id' element in books Id = Int32.Parse(BookElement.GetElementsByTagName("id")[0].InnerText), //A Title member, equal to the first 'title' in the xml Title = BookElement.GetElementsByTagName("title")[0].InnerText }; //Create a new XML Element equal to the first 'author' element books XmlElement Author = (XmlElement)BookElement.GetElementsByTagName("author")[0]; //A member equal to the first 'firstname' element in the 'author' element in books NewBook.FirstName = Author.GetElementsByTagName("firstname")[0].InnerText; //Create a middle name member equal to an empty string NewBook.MiddleName = ""; //Check if there is a middle name in the 'author' element if (BookElement.GetElementsByTagName("middlename").Count > 0) { //if there is, set it to the value of the first 'middlename' in the 'author' element in books NewBook.MiddleName = Author.GetElementsByTagName("middlename")[0].InnerText; }//Otherwise, keep the 'MiddleName' value an empty string //A LastName member equal to the value of the first 'lastname' element in the 'author' element in books NewBook.LastName = Author.GetElementsByTagName("lastname")[0].InnerText; //Set the AuthorTitle the value of the 'title' attribute NewBook.AuthorTitle = Author.GetAttribute("title"); //Add the NewBook to the new BookList BookList.Add(NewBook); } } //Return the View containing the BookList return(View(BookList)); }
public BookElementViewModel(BookElement bookElement) { this.Id = Id; this.Name = bookElement.Name; }
public void EditBookElement(BookElement bookElement) { this.bookElementSetWrapper.Update(bookElement); this.SaveChanges(); }
public void CreateBookElementWithNewGuid(BookElement bookElement) { this.CreateGuid(bookElement); this.bookElementSetWrapper.Add(bookElement); this.SaveChanges(); }