internal void PrepareForCreateNew() { foreach (var a in _unitOfWork.Repo.GetAuthors()) { AuthorSelectList.Add(new SelectListItem { Text = a.FullName, Value = a.AuthorId.ToString(), }); } }
/// <summary> /// Fills AuthorSelectList and AuthorName string property /// </summary> /// <param name="id">Id from BOOOK MODEL!!!!</param> internal void PreparForEdit(int id) { var book = _unitOfWork.Repo.GetBooks().FirstOrDefault(b => b.BookId == id); //micanje starog autora var oldAuthor = _unitOfWork.Repo.GetAuthors().FirstOrDefault(b => b.AuthorId == book.AuthorId); oldAuthor.Books.Remove(book); foreach (var a in _unitOfWork.Repo.GetAuthors()) { AuthorSelectList.Add(new SelectListItem { Text = a.FullName, Value = a.AuthorId.ToString(), }); } }