generated from revature-curriculum/pep-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package Service; | ||
|
||
import Model.Message; | ||
import DAO.MessageDAO; | ||
import DAO.AccountDAO; | ||
|
||
public class MessageService { | ||
MessageDAO messageDAO; | ||
AccountDAO accountDAO; | ||
|
||
public MessageService() { | ||
messageDAO = new MessageDAO(); | ||
accountDAO = new AccountDAO(); | ||
} | ||
|
||
public MessageService(MessageDAO messageDAO){ | ||
this.messageDAO = messageDAO; | ||
accountDAO = new AccountDAO(); | ||
} | ||
|
||
public MessageService(MessageDAO messageDAO, AccountDAO accountDAO) { | ||
this.messageDAO = messageDAO; | ||
this.accountDAO = accountDAO; | ||
} | ||
|
||
public boolean messageIsValid(int posted_by, String message_text) { | ||
if (message_text.length() == 0 || message_text.length() > 255) return false; | ||
else if (accountDAO.findAccountByAccountId(posted_by) == null) return false; | ||
else return true; | ||
} | ||
|
||
public Message insertMessage(int posted_by, String message_text, long time_posted_epoch) { | ||
return messageDAO.insertMessage(posted_by, message_text, time_posted_epoch); | ||
} | ||
|
||
} |