<?php
class SoftController extends Easy_Controller_Action {
	public function Init(){
		$this->_Soft = new SoftModel();
	}
	public function IndexAction(){
		$this->_View->soft = $this->_Soft->getAll();
	}
	public function addAction(){
		if ($this->_Request->isPost()){
			if ($this->_Soft->add($this->_Request->getPost()) ===false){
				$this->_View->message = $this->_Soft->error;
			}else{
				$this->_View->message = _('添加成功!');
			}
			exit($this->_View->Render('message'));
		}
	}
	public function modifyAction(){
		if ($this->_Request->isPost()){
			if ($this->_Soft->modify($this->_Request->getPost())===false){
				$this->_View->message = $this->_Soft->error;
			}else{
				$this->_View->message = _('修改成功!');
			}
			exit($this->_View->Render('message'));
		}else{
			$this->_View->modify = $this->_Soft->getRow((int)$this->_Request->getParam('id'));
		}
	}
	public function deleteAction(){
		$this->_Soft->delete($this->_Request->getParam('id'));
		$this->_View->message = _('删除成功!');
		exit($this->_View->Render('message'));
	}
}
?>
