Created
January 3, 2016 20:17
-
-
Save jesulink2514/96fe3cc5832310e9c067 to your computer and use it in GitHub Desktop.
Controlador con auditoria manual
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
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