CONTROLLO LOGIN 2 + CONTROLLO ERRORE CAMPO COD FIS SU CREATE
This commit is contained in:
parent
76b064389f
commit
5b51e4f593
@ -43,8 +43,11 @@ namespace VirtualTask.Controllers
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
token = helper.GetStringValue("tok");
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
return RedirectToAction("Index", "Login");
|
||||
{
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
admin = helper.GetStringValue("admin");
|
||||
@ -110,6 +113,10 @@ namespace VirtualTask.Controllers
|
||||
[HttpPost]
|
||||
public IActionResult Create(Anag model)
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
admin = helper.GetStringValue("admin");
|
||||
ViewBag.Admin = admin;
|
||||
|
||||
AnagCommImp anagCommImp = new AnagCommImp();
|
||||
|
||||
if (ModelState.IsValid)
|
||||
@ -130,17 +137,16 @@ namespace VirtualTask.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(sCodFis))
|
||||
{
|
||||
bparivaOK = true;
|
||||
bcodfiscOK = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bcodfiscOK = CodiceFiscale.VerificaCodiceFiscale(sCodFis);
|
||||
|
||||
}
|
||||
|
||||
if (!bcodfiscOK)
|
||||
{
|
||||
ModelState.AddModelError("andescri", "Codice Fiscale non corretto");
|
||||
ModelState.AddModelError("ancodfis", "Codice Fiscale non corretto");
|
||||
}
|
||||
if (!bparivaOK)
|
||||
{
|
||||
@ -149,7 +155,7 @@ namespace VirtualTask.Controllers
|
||||
|
||||
if (bcodfiscOK && bparivaOK)
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
//SessionHelper helper = new SessionHelper(this);
|
||||
|
||||
token = helper.GetStringValue("tok");
|
||||
tenant = helper.GetStringValue("tenant");
|
||||
@ -312,33 +318,78 @@ namespace VirtualTask.Controllers
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
|
||||
token = helper.GetStringValue("tok");
|
||||
tenant = helper.GetStringValue("tenant");
|
||||
model.ancodazi = tenant;
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
urlBase = apiUrl + "anagrafiche/mod";
|
||||
urlBase = urlBase + "?token=" + token;
|
||||
Uri baseAddress = new Uri(urlBase);
|
||||
client = new HttpClient();
|
||||
client.BaseAddress = baseAddress;
|
||||
admin = helper.GetStringValue("admin");
|
||||
ViewBag.Admin = admin;
|
||||
|
||||
string data = JsonConvert.SerializeObject(model);
|
||||
bool bcodfiscOK = false;
|
||||
bool bparivaOK = false;
|
||||
string sCodFis = !string.IsNullOrEmpty(model.ancodfis) ? model.ancodfis : string.Empty;
|
||||
string sParIva = !string.IsNullOrEmpty(model.anpariva) ? model.anpariva : string.Empty;
|
||||
|
||||
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
||||
|
||||
HttpResponseMessage response = client.PostAsync(baseAddress, content).Result;
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
if (string.IsNullOrEmpty(sParIva))
|
||||
{
|
||||
return RedirectToAction("Index");
|
||||
bparivaOK = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
errMes = response.Content.ReadAsStringAsync().Result;
|
||||
helper.SetStringValue("errMsg", errMes);
|
||||
return RedirectToAction("Error");
|
||||
bparivaOK = _checkVatItaFormale("IT", sParIva);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(sCodFis))
|
||||
{
|
||||
bcodfiscOK = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bcodfiscOK = CodiceFiscale.VerificaCodiceFiscale(sCodFis);
|
||||
|
||||
}
|
||||
|
||||
if (!bcodfiscOK)
|
||||
{
|
||||
ModelState.AddModelError("ancodfis", "Codice Fiscale non corretto");
|
||||
}
|
||||
if (!bparivaOK)
|
||||
{
|
||||
ModelState.AddModelError("anpariva", "Partita Iva non corretta");
|
||||
}
|
||||
|
||||
|
||||
if (bcodfiscOK && bparivaOK)
|
||||
{
|
||||
//SessionHelper helper = new SessionHelper(this);
|
||||
|
||||
token = helper.GetStringValue("tok");
|
||||
tenant = helper.GetStringValue("tenant");
|
||||
model.ancodazi = tenant;
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
urlBase = apiUrl + "anagrafiche/mod";
|
||||
urlBase = urlBase + "?token=" + token;
|
||||
Uri baseAddress = new Uri(urlBase);
|
||||
client = new HttpClient();
|
||||
client.BaseAddress = baseAddress;
|
||||
|
||||
string data = JsonConvert.SerializeObject(model);
|
||||
|
||||
StringContent content = new StringContent(data, Encoding.UTF8, "application/json");
|
||||
|
||||
HttpResponseMessage response = client.PostAsync(baseAddress, content).Result;
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
else
|
||||
{
|
||||
errMes = response.Content.ReadAsStringAsync().Result;
|
||||
helper.SetStringValue("errMsg", errMes);
|
||||
return RedirectToAction("Error");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return View("Edit", model);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion EDIT
|
||||
|
||||
@ -35,8 +35,13 @@ namespace VirtualTask.Controllers
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
token = helper.GetStringValue("tok");
|
||||
//if (string.IsNullOrEmpty(token))
|
||||
// return RedirectToAction("Index", "Login");
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
return RedirectToAction("Index", "Login");
|
||||
{
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
admin = helper.GetStringValue("admin");
|
||||
@ -109,7 +114,7 @@ namespace VirtualTask.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
return RedirectToAction("Index", "Login");
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
|
||||
model.pirifazi = tenant;
|
||||
@ -227,7 +232,7 @@ namespace VirtualTask.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
return RedirectToAction("Index", "Login");
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
|
||||
model.pirifazi = token;
|
||||
|
||||
@ -40,8 +40,9 @@ namespace VirtualTask.Controllers
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
token = helper.GetStringValue("tok");
|
||||
if (string.IsNullOrEmpty(token))
|
||||
return RedirectToAction("Index", "Login");
|
||||
|
||||
{
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
admin = helper.GetStringValue("admin");
|
||||
ViewBag.Admin = admin;
|
||||
@ -116,7 +117,7 @@ namespace VirtualTask.Controllers
|
||||
tenant = helper.GetStringValue("tenant");
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
return RedirectToAction("Index","Login");
|
||||
return RedirectToAction("Login2","Login");
|
||||
}
|
||||
|
||||
#region campi da impostare
|
||||
@ -268,7 +269,7 @@ namespace VirtualTask.Controllers
|
||||
tenant = helper.GetStringValue("tenant");
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
return RedirectToAction("Index", "Login");
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
model.chcodazi = tenant;
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
|
||||
@ -38,7 +38,9 @@ namespace VirtualTask.Controllers
|
||||
token = helper.GetStringValue("tok");
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
return RedirectToAction("Index", "Login");
|
||||
{
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
admin = helper.GetStringValue("admin");
|
||||
@ -109,7 +111,7 @@ namespace VirtualTask.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
return RedirectToAction("Index", "Login");
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
|
||||
model.cccodazi = tenant;
|
||||
|
||||
@ -39,8 +39,12 @@ namespace VirtualTask.Controllers
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
token = helper.GetStringValue("tok");
|
||||
|
||||
//if (string.IsNullOrEmpty(token))
|
||||
// return RedirectToAction("Index", "Login");
|
||||
if (string.IsNullOrEmpty(token))
|
||||
return RedirectToAction("Index", "Login");
|
||||
{
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
admin = helper.GetStringValue("admin");
|
||||
@ -122,7 +126,7 @@ namespace VirtualTask.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
return RedirectToAction("Index", "Login");
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
|
||||
model.lacodazi = tenant;
|
||||
|
||||
@ -36,9 +36,11 @@ namespace VirtualTask.Controllers
|
||||
{
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
token = helper.GetStringValue("tok");
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
return RedirectToAction("Index", "Login");
|
||||
{
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
admin = helper.GetStringValue("admin");
|
||||
@ -106,8 +108,14 @@ namespace VirtualTask.Controllers
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
token = helper.GetStringValue("tok");
|
||||
tenant = helper.GetStringValue("tenant");
|
||||
|
||||
//if (string.IsNullOrEmpty(token))
|
||||
// return RedirectToAction("Index", "Login");
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
return RedirectToAction("Index", "Login");
|
||||
{
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
model.imcodazi = tenant;
|
||||
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
|
||||
@ -36,7 +36,9 @@ namespace VirtualTask.Controllers
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
token = helper.GetStringValue("tok");
|
||||
if (string.IsNullOrEmpty(token))
|
||||
return RedirectToAction("Index", "Login");
|
||||
{
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
admin = helper.GetStringValue("admin");
|
||||
|
||||
@ -36,7 +36,9 @@ namespace VirtualTask.Controllers
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
token = helper.GetStringValue("tok");
|
||||
if (string.IsNullOrEmpty(token))
|
||||
return RedirectToAction("Index", "Login");
|
||||
{
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
admin = helper.GetStringValue("admin");
|
||||
|
||||
@ -18,19 +18,9 @@ namespace VirtualTask.Controllers
|
||||
string errMes = string.Empty;
|
||||
string admin = string.Empty;
|
||||
|
||||
//MF commentati perchè L'Uri viene costruito
|
||||
//Uri baseAddress = new Uri("http://10.0.0.187:8000/api/Polo/tecniciList?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiVEVTVCIsImp0aSI6IjA2MzA5MzlmLTBhZDgtNDhkMi04ZTI5LWI3Mjk3N2IyOWM1YiIsInRlbmFudCI6Ik1BUlJPIiwidGNjb2RpY2UiOiJaWlogICAgICAgICAgICAiLCJleHAiOjE3MDE3Njk0NTUsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjE5NTUiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.CDt3wR6ube4zzNscVG9Qv6bzOnNF6A9-bIZxxjbKmKI");
|
||||
HttpClient client;
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
//Uri baseAddressCreate = new Uri("http://10.0.0.187:8000/api/Polo/tecnici/add?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiVEVTVCIsImp0aSI6IjA2MzA5MzlmLTBhZDgtNDhkMi04ZTI5LWI3Mjk3N2IyOWM1YiIsInRlbmFudCI6Ik1BUlJPIiwidGNjb2RpY2UiOiJaWlogICAgICAgICAgICAiLCJleHAiOjE3MDE3Njk0NTUsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjE5NTUiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.CDt3wR6ube4zzNscVG9Qv6bzOnNF6A9-bIZxxjbKmKI");
|
||||
//HttpClient clientCreate;
|
||||
|
||||
//Uri baseAddressEdit = new Uri("http://10.0.0.187:8000/api/Polo/tecnici/mod?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiVEVTVCIsImp0aSI6IjA2MzA5MzlmLTBhZDgtNDhkMi04ZTI5LWI3Mjk3N2IyOWM1YiIsInRlbmFudCI6Ik1BUlJPIiwidGNjb2RpY2UiOiJaWlogICAgICAgICAgICAiLCJleHAiOjE3MDE3Njk0NTUsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjE5NTUiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.CDt3wR6ube4zzNscVG9Qv6bzOnNF6A9-bIZxxjbKmKI");
|
||||
//HttpClient clientEdit;
|
||||
|
||||
//Uri baseAddressDelete = new Uri("http://10.0.0.187:8000/api/Polo/tecnici/del?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiVEVTVCIsImp0aSI6IjA2MzA5MzlmLTBhZDgtNDhkMi04ZTI5LWI3Mjk3N2IyOWM1YiIsInRlbmFudCI6Ik1BUlJPIiwidGNjb2RpY2UiOiJaWlogICAgICAgICAgICAiLCJleHAiOjE3MDE3Njk0NTUsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NjE5NTUiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.CDt3wR6ube4zzNscVG9Qv6bzOnNF6A9-bIZxxjbKmKI");
|
||||
//HttpClient clientDelete;
|
||||
|
||||
public TecniciController(IConfiguration configuration)
|
||||
{
|
||||
@ -47,7 +37,9 @@ namespace VirtualTask.Controllers
|
||||
SessionHelper helper = new SessionHelper(this);
|
||||
token = helper.GetStringValue("tok");
|
||||
if (string.IsNullOrEmpty(token))
|
||||
return RedirectToAction("Index", "Login");
|
||||
{
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
|
||||
apiUrl = helper.GetStringValue("apiUrl");
|
||||
admin = helper.GetStringValue("admin");
|
||||
@ -118,7 +110,7 @@ namespace VirtualTask.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
return RedirectToAction("Index", "Login");
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
model.tccodazi = tenant;
|
||||
|
||||
@ -218,7 +210,6 @@ namespace VirtualTask.Controllers
|
||||
string data = response.Content.ReadAsStringAsync().Result;
|
||||
modelList = JsonConvert.DeserializeObject<List<Tecnici>>(data);
|
||||
tecnico = modelList.Where(x => x.tccodice.Equals(id)).First();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -240,7 +231,7 @@ namespace VirtualTask.Controllers
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
return RedirectToAction("Index", "Login");
|
||||
return RedirectToAction("Login2", "Login");
|
||||
}
|
||||
tecnico.tccodazi = tenant;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user