private static BookData ConvertBookToBookData(Book b) { BookData result = new BookData(); result.ID = b.ID; result.Name = b.name; result.ISBN = b.ISBN; result.Price = (double)b.price; result.Quantity = (int)b.quantity; result.Status = b.status; result.Thumnail = b.thumbnail; result.Description = b.description; result.Publisher_ID = (int)b.publisher_ID; result.Year = b.year; result.Author = new List <AuthorData>(); foreach (Book_Author item in b.Book_Author) { AuthorData temp = new AuthorData(); temp.ID = (int)item.Author.ID; temp.name = item.Author.name; result.Author.Add(temp); } result.Category = new List <CategoryData>(); foreach (Book_Category item in b.Book_Category) { CategoryData temp = new CategoryData(); temp.ID = item.Category.ID; temp.name = item.Category.name; temp.status = item.Category.status; result.Category.Add(temp); } return(result); }
public void Initialize(AuthorData data, string message) { avatarImage.sprite = data.AvatarSprite; messageTextElement.Initialize(data.WriterName, message); SetVisualState(VisualMessageElementState.Last); SetRemoveButtonState(false); }
private void btnAdd_Click(object sender, EventArgs e) { if (!validate()) { return; } if (String.IsNullOrEmpty(txtName.Text)) { MessageBox.Show("Author name must not empty"); return; } AuthorData author = new AuthorData() { name = txtName.Text }; bool result = proxy.AddAuthor(author); if (result) { MessageBox.Show("Add author successful!"); getDataScource(); } else { MessageBox.Show("Add author Fail!"); } }
static void Main(string[] args) { // without repository AuthorData author = new AuthorData(); author.Name = "name"; var dlContext = new DLContext(); dlContext.Authors.Add(author); dlContext.SaveChanges(); var users = dlContext.Users.Include(x => x.DepartmentID).ToList(); var user = dlContext.Users.FirstOrDefault(x => x.ID == 1); dlContext.Departments.Where(x => x.ID == user.DepartmentID).Load(); // with repository using (var unitOfWork = new UnitOfWork(new DLContext())) { var user1 = unitOfWork.Users.Get(1); var newUser = new UserData(); newUser.UserName = "******"; unitOfWork.Users.Add(newUser); unitOfWork.Complete(); unitOfWork.Users.Remove(newUser); unitOfWork.Complete(); } }
protected override void ProcessElement(BookData bookData, XmlReader xmlReader) { string name = GetInnerContentAsString(xmlReader); AuthorData author = new AuthorData { Name = name }; bookData.Authors.Add(author); }
public bool AddAuthor(AuthorData a) { Author author = new Author(); author.name = a.name; bool result = AuthorService.Add(author); return(result); }
public bool RemoveAuthor(AuthorData a) { Author author = new Author(); author.ID = a.ID; author.name = a.name; bool result = AuthorService.Remove(author); return(result); }
public bool UpdateAuthor(AuthorData a) { Author author = new Author(); author.name = a.name; author.ID = a.ID; bool result = AuthorService.Update(author); return(result); }
public ActionResult Post([FromBody] AuthorData authorData) { var author = new Author { FirstName = authorData.FirstName, LastName = authorData.LastName }; DbContext.Add(author); DbContext.SaveChanges(); return(Ok("Author added")); }
public static List <AuthorData> GetAllBookAuthorData() { using (Book_Sale_ManagerEntities contex = new Book_Sale_ManagerEntities()) { List <Author> authors = contex.Authors.ToList(); List <AuthorData> result = new List <AuthorData>(); foreach (var item in authors) { AuthorData a = new AuthorData(); a.ID = item.ID; a.name = item.name; result.Add(a); } return(result); } }
public bool Validate() { bool validGenre; using (GenreData genreData = new GenreData()) { validGenre = genreData.GetGenreIdByName(Genre) >= 0; } bool validType; using (TypeData typeData = new TypeData()) { validType = typeData.GetTypeIdByName(Type) >= 0; } bool validAuthorId; using (AuthorData authorData = new AuthorData()) { validAuthorId = authorData.GetAuthorById(Author.AuthorId) != null; } bool validUserName; using (UserData userData = new UserData()) { validUserName = userData.GetUserByUserName(User.UserName) != null; } if (!validGenre || !validType || !validAuthorId || !validUserName || String.IsNullOrEmpty(Title) || Year < 0 || String.IsNullOrEmpty(Isbn)) { return(false); } return(true); }
public bool ValidateEdit() { bool validBookId; using (BookData genreData = new BookData()) { validBookId = genreData.GetBookById(BookId) != null; } bool validGenre; using (GenreData genreData = new GenreData()) { validGenre = genreData.GetGenreIdByName(Genre) >= 0; } bool validType; using (TypeData typeData = new TypeData()) { validType = typeData.GetTypeIdByName(Type) >= 0; } bool validAuthorId; using (AuthorData authorData = new AuthorData()) { validAuthorId = authorData.GetAuthorById(Author.AuthorId) != null; } if (!validGenre || !validType || !validAuthorId || !validBookId || String.IsNullOrEmpty(Title) || Year < 0 || String.IsNullOrEmpty(Isbn)) { return(false); } return(true); }
public OperationResultSet <Author> GetAllAuthors(string userName, string guid) { if (!CheckAuthenticated(userName, guid)) { return(new OperationResultSet <Author>(Library.Models.OperationResult.ErrorEnum.NotAuthenticated, "Please authenticate first!")); } using (AuthorData dataProvider = new AuthorData()) { try { OperationResultSet <Author> authors = new OperationResultSet <Author>(new List <Author>(dataProvider.GetAllAuthors())); return(authors); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("BookManagement : GetAllAuthors : " + ex.StackTrace); return(new OperationResultSet <Author>(Library.Models.OperationResult.ErrorEnum.InternalProblem, "Some internal problem has occured")); } } }
static void Main(string[] args) { LanguageData.init(); AuthorData.init(); Console.WriteLine(LanguageData.languages[0].GetData()); Console.WriteLine(LanguageData.languages[2].GetData()); Console.WriteLine(AuthorData.authors[0].GetData()); Console.WriteLine(AuthorData.authors[2].GetData()); AccessoryLanguageData dataAccessory = new AccessoryLanguageData("Markup language", "W3C HTML 5.2"); ProgrammingLanguageData dataProgramming = new ProgrammingLanguageData("OOP", "static strong"); LanguageData.languages.Add((AuthorData.authors[2] as LanguageAuthorBase).CreateLanguage("NEW NAME", 2018, dataAccessory)); LanguageData.languages.Add((AuthorData.authors[3] as LanguageAuthorBase).CreateLanguage("NEW NAME", 2018, dataProgramming)); Console.Read(); }
public static void Main() { var host = CreateHostBuilder(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; var context = services.GetRequiredService <WebAppDBContext>(); AccountData.Initialize(context); AdminData.Initialize(context); FunctionData.Initialize(context); ProductData.Initialize(context); ProductTypeData.Initialize(context); SaleData.Initialize(context); RegionData.Initialize(context); ProvinceData.Initialize(context); WardData.Initialize(context); AuthorData.Initialize(context); } host.Run(); }
public OperationResult AddAuthor(Author author, string userName, string guid) { if (!CheckAuthenticated(userName, guid)) { return(new OperationResult(Library.Models.OperationResult.ErrorEnum.NotAuthenticated, "Please authenticate first!")); } if (author == null || !author.Validate()) { return(new OperationResult(Library.Models.OperationResult.ErrorEnum.InvalidInputData, "Invalid first name or last name")); } try { using (AuthorData authorData = new AuthorData()) { authorData.AddAuthor(author); return(new OperationResult()); } } catch (Exception ex) { return(new OperationResult(Library.Models.OperationResult.ErrorEnum.InternalProblem, "Some internal problem has occured")); } }
private void ShowAuthorRecord(object sender, EventArgs e) { AuthorData Data = new AuthorData("Book Author", TheUser); EntityForm = new EntityForm(this, Data); }
// GET: api/Author public List <AuthorModel> Get() { AuthorData data = new AuthorData(); return(data.GetAuthors()); }
// GET: api/Author/5 public List <AuthorModel> GetById(int id) { AuthorData data = new AuthorData(); return(data.GetAuthorById(id)); }
public void Put([FromBody] AuthorData author) { var authorPL = _mapper.Map <AuthorModel>(author); _service.Update(authorPL); }
public AuthorBusiness(BookStoreContext context) { _authorData = new AuthorData(context); }