Skip to content

Instantly share code, notes, and snippets.

@jesulink2514
Created January 3, 2016 20:17
Show Gist options
  • Save jesulink2514/96fe3cc5832310e9c067 to your computer and use it in GitHub Desktop.
Save jesulink2514/96fe3cc5832310e9c067 to your computer and use it in GitHub Desktop.
Controlador con auditoria manual
using System.Web.Mvc;
using AuditSample.Models;
using Microsoft.AspNet.Identity;
namespace AuditSample.Controllers
{
[Authorize]
public class PizzaController : Controller
{
private readonly IApplicationService _applicationService;
public PizzaController(IApplicationService applicationService)
{
_applicationService = applicationService;
}
// GET: Pizza/Create
public ActionResult Create()
{
return View();
}
// POST: Pizza/Create
[HttpPost]
public ActionResult Create(Pizza nueva)
{
if (ModelState.IsValid)
{
//Agregar detalles de auditoria de manera manual
nueva.UserId = User.Identity.GetUserId();
nueva.Ip = HttpContext.Request.UserHostAddress;
var response = applicationService.create(nueva);
if (response.IsCorrect)
return View("_Success", response);
}
return View(nueva);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment