public IActionResult Index([FromForm] Login login) { //HttpContext.Session.SetString("Test", "Ben Rules!"); ViewData["Api"] = _endPoint; var ad = new AdaptadorAtc(_configuration); var ipaddress = _accessor.HttpContext.Connection.RemoteIpAddress.ToString(); var us = ad.UsuariosLogin(login.email, login.password, ipaddress); if (us.IdUsuarioWeb > 0) { us.InfoMenuWeb = ad.InfoMenuWebLeer(); us.Mensajes = ad.MensajeLeer(us.Cliente.IDCliente, 0); us.DatosEmpresa = ad.DatosEmpresaLeer(us.IdUsuarioWeb); HttpContext.Session.SetObjectAsJson("Login", us); var vm = new IndexViewModel(_configuration); ViewData["Vehiculos"] = vm.Vehiculos; ViewData["UnClick"] = vm.UnClick; ViewData["Novedades"] = vm.Novedades; ViewData["Test"] = HttpContext.Session.GetString("Test"); ViewData["Usuario"] = HttpContext.Session.GetObjectFromJson <UsuarioWeb>("Login"); return(View()); } else { //var msj = new MensajeError(); return(RedirectToAction("Incorrecta", _defaultController)); } }
public IActionResult MensajeMarcarLeido(int idMensaje, int idCliente) { ObjectResult result; var ad = new AdaptadorAtc(_configuration); try { //var res = new LecturasViewModel(_configuration, bs); ad.MensajeMarcarLeido(idMensaje, idCliente); var us = HttpContext.Session.GetObjectFromJson <UsuarioWeb>("Login"); us.Mensajes = ad.MensajeLeer(idCliente, 0); HttpContext.Session.SetObjectAsJson("Login", us); result = new ObjectResult(1) { StatusCode = (int)HttpStatusCode.OK }; } catch (Exception ex) { result = new ObjectResult(ex) { StatusCode = (int)HttpStatusCode.Conflict }; Request.HttpContext.Response.Headers.Add("dsError", ex.Message); } return(result); }