-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAtualizar_UsuariosController.cs
146 lines (117 loc) · 3.98 KB
/
Atualizar_UsuariosController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
using padvMVC.Negocio;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using padvMVC.Models;
namespace padvMVC.Controllers
{
public class Atualizar_UsuariosController : GeralController
{
// GET: AtualizarUsuarios
[RedirectingAction]
[RefreshAttribute]
public ActionResult Index()
{
Exist_UsersDto usuario = getUser();
GetDropDownRegioes();
paises();
tratamentos();
ViewBag.usuario = usuario;
return View();
}
public ActionResult LoadDropDownPaises()
{
try
{
paises();
return Json(new { status = "success" });
}
catch (Exception ex)
{
return Json(new { status = "error" });
}
}
public ActionResult LoadGridUsuarios(string texto, string coluna)
{
try
{
List<Exist_UsersDto> usuarios = new List<Exist_UsersDto>();
if (texto != null)
{
if (texto == "")
{
exist_users exist_users = new exist_users();
usuarios = exist_users.ConsultarUsuarios();
usuarios = usuarios.Where(f => f.user_admin == false).ToList();
TempData["collection_users"] = usuarios;
}
else
{
usuarios = (List<Exist_UsersDto>)TempData["collection_users"];
TempData.Keep("collection_users");
usuarios = Buscar(usuarios, texto, coluna);
ViewBag.defaultSort = coluna;
}
}
else
{
usuarios = (List<Exist_UsersDto>)TempData["collection_users"];
TempData.Keep("collection_users");
}
var SchemeList = (from scheme in usuarios select scheme).ToList();
return PartialView("GridUsuarios", SchemeList);
}
catch (Exception ex)
{
return Content("<label> Erro. Contacte o administrador </label>");
}
}
public ActionResult Incluir(Exist_UsersDto model)
{
try
{
RemoveReferences(ModelState, "country_id");
//if (!ModelState.IsValid)
//{
// return Json(new { status = "validation", view = "" });
//}
exist_users exist_users = new exist_users();
string retorno = exist_users.Incluir(model);
return Json(new { status = "success" });
}
catch (Exception ex)
{
return Json(new { status = "error" });
}
}
public ActionResult Editar(Exist_UsersDto model)
{
try
{
RemoveReferences(ModelState, "country_id");
exist_users exist_users = new exist_users();
string retorno = exist_users.Editar(model);
return Json(new { status = "success" });
}
catch (Exception ex)
{
return Json(new { status = "error" });
}
}
public ActionResult Excluir(Exist_UsersDto model)
{
try
{
exist_users user = new exist_users();
user.Excluir(model.user_id);
return Json(new { status = "success" });
}
catch (Exception ex)
{
return Json(new { status = "error" });
}
}
}
}