I have an ASP.NET MVC project. In this project, I have a controller named MessageController. I have 2 methods in this controller, one is HttpGet and the other is HttpPost.
I want to run an operation like this in my method with HttpPost attribute. If the first button in the view is clicked, it will be an operation, if the second button is clicked, it will be another operation.
How can I do this operation?
Here is my code:
public class MessageController : Controller
{
MessageManager mg = new MessageManager(new EfMessageDal());
[HttpGet]
public ActionResult NewMessage()
{
return View();
}
[HttpPost]
public ActionResult NewMessage(Message p)
{
MessageValidator messagevalidator = new MessageValidator();
ValidationResult result = messagevalidator.Validate(p);
if (result.IsValid)
{
if (//clicking button1)
{
//operate first operation
}
else
//operate second operation
}
else
{
//Error Messages
}
return View();
}
}