public bool Update(int?id, ErrorBankParam errorBankParam) { var result = 0; var errorBank = Get(id); errorBank.Message = errorBankParam.Message; errorBank.Description = errorBankParam.Description; errorBank.Solution = errorBankParam.Solution; errorBank.Date = DateTimeOffset.Now.LocalDateTime; errorBank.students = _context.Students.Find(errorBankParam.students); errorBank.departments = _context.Departments.Find(errorBankParam.departments); errorBank.UpdateDate = DateTimeOffset.Now.LocalDateTime; result = _context.SaveChanges(); if (result > 0) { status = true; MessageBox.Show("Update Successfully"); } else { MessageBox.Show("Update Failed"); } return(status); }
public bool Insert(ErrorBankParam errorBankParam) { if (errorBankParam.Message.ToString() == " ") { MessageBox.Show("Don't insert white space"); } else { status = _errorBankRepository.Insert(errorBankParam); } return(status); }
public bool Update(int?id, ErrorBankParam errorBankParam) { if (_errorBankRepository.Get(id) == null) { MessageBox.Show("Sorry, your data is not found"); } else if (id.ToString() == " ") { MessageBox.Show("Don't insert white space in Id"); } else { if (errorBankParam.Message.ToString() == " ") { MessageBox.Show("Don't insert white space in Name"); } else { status = _errorBankRepository.Update(id, errorBankParam); } } return(status); }
public bool Insert(ErrorBankParam errorBankParam) { var result = 0; errorBank.Message = errorBankParam.Message; errorBank.Description = errorBankParam.Description; errorBank.Solution = errorBankParam.Solution; errorBank.Date = DateTimeOffset.Now.LocalDateTime; errorBank.students = _context.Students.Find(errorBankParam.students); errorBank.departments = _context.Departments.Find(errorBankParam.departments); errorBank.CreateDate = DateTimeOffset.Now.LocalDateTime; _context.ErrorBanks.Add(errorBank); result = _context.SaveChanges(); if (result > 0) { status = true; MessageBox.Show("Insert Successfully"); } else { MessageBox.Show("Insert Failed"); } return(status); }