public IActionResult Viaje(int id) { GetterAll getter = new GetterAll(_getterUtils, _context); var it = (getter.GetAll("Itinerario") as IEnumerable <Itinerario>).Where(x => x.ItinerarioID == id).Single(); var viajes = (getter.GetAll("Viaje") as IEnumerable <Viaje>).Where(x => x.Itinerario.ItinerarioID == id); return(View(viajes)); }
public IActionResult CreateVisa() { var getter = new GetterAll(_getterUtils, _context); var countries = getter.GetAll("Pais").Select(x => (x as Pais).Nombre); var regions = getter.GetAll("Region").Select(x => (x as Region).Nombre); return(View(new VisaViewModel() { paisesNames = countries, regionesName = regions })); }
public IActionResult UpdatePais(PaisCommand cmd) { var getter = new GetterAll(_getterUtils, _context); if (ModelState.IsValid) { var pais = (getter.GetAll("Pais") as IEnumerable <Pais>).Where(x => x.PaisID == cmd.Id).Single(); AdminService service = new AdminService(_context, _userManager, _getterUtils); service.UpdatePais(cmd.ToPais(), pais); return(RedirectToAction("EditPais")); } cmd.Regiones = (getter.GetAll("Region") as IEnumerable <Region>).Select(x => x.Nombre); return(View(cmd)); }
public IActionResult Create() { var getter = new GetterAll(_getterUtils, _context); var data = getter.GetAll("Pais").Select(x => (x as Pais).Nombre); return(View(data)); }
public IActionResult EditVisa() { var getter = new GetterAll(_getterUtils, _context); var visas = (getter.GetAll("Visa") as IEnumerable <Visa>); return(View(visas)); }
public IActionResult Visa(int Id) { var getter = new GetterAll(_getterUtils, _context); var visa = (getter.GetAll("Visa") as IEnumerable <Visa>).Where(x => x.VisaID == Id).Single(); return(View(visa)); }
public IActionResult UpdatePais(int key) { var getter = new GetterAll(_getterUtils, _context); var pais = (getter.GetAll("Pais") as IEnumerable <Pais>).Where(x => x.PaisID == key).Single(); return(View(new PaisCommand { Id = key, Name = pais.Nombre, RegionName = pais.Region.Nombre, Regiones = (getter.GetAll("Region") as IEnumerable <Region>).Select(x => x.Nombre) })); }
public IActionResult UpdateRegion(int id) { var getter = new GetterAll(_getterUtils, _context); var region = (getter.GetAll("Region") as IEnumerable <Region>).Where(x => x.RegionID == id).Single(); return(View(new RegionViewModel { Nombre = region.Nombre, Id = region.RegionID })); }
public async Task <(List <string> UserPendings, List <Itinerario> ViajesUpdated, List <ViajeInvitado> InvitadosUpdated)> FillNotificationsAsync() { //check for pending users List <string> UserPendings = new List <string>(); foreach (var user in _userManager.Users) { if ((await _userManager.GetClaimsAsync(user)).Any(c => c.Type == "Pending" && c.Value == "true")) { UserPendings.Add(user.Email); } } GetterAll getter = new GetterAll(_getterUtils, _context); List <Itinerario> ViajesUpdated = getter.GetAll("Itinerario").Where(i => (i as Itinerario).Update != 0).Select(i => i as Itinerario).ToList(); List <ViajeInvitado> InvitadosUpdated = getter.GetAll("ViajeInvitado").Where(vi => (vi as ViajeInvitado).Update != 0).Select(vi => vi as ViajeInvitado).ToList(); return(UserPendings, ViajesUpdated, InvitadosUpdated); }
public IActionResult UpdateVisa(int id) { var getter = new GetterAll(_getterUtils, _context); var data = new EditVisaViewModel() { id = id }; data.paisesNames = getter.GetAll("Pais").Select(x => (x as Pais).Nombre); data.regionesName = getter.GetAll("Region").Select(x => (x as Region).Nombre); var visa = getter.GetAll("Visa") .Select(x => (x as Visa)) .Where(x => x.VisaID == id) .Single(); data.Nombre = visa.Name; data.SelectedPais = visa.Paises != null?visa.Paises.Select(x => x.Pais.Nombre) : new List <string>(); data.SelectedRegion = visa.Regiones != null?visa.Regiones.Select(x => x.Region.Nombre) : new List <string>(); return(View(data)); }
public IActionResult AddPais(PaisCommand cmd) { if (ModelState.IsValid) { AdminService service = new AdminService(_context, _userManager, _getterUtils); service.RegisterPais(cmd, out var errors); return(RedirectToAction("EditPais")); } var getter = new GetterAll(_getterUtils, _context); cmd.Regiones = (getter.GetAll("Region") as IEnumerable <Region>).Select(x => x.Nombre); return(View(cmd)); }
public IActionResult UpdateRegion(RegionViewModel cmd) { var getter = new GetterAll(_getterUtils, _context); if (ModelState.IsValid) { var region = (getter.GetAll("Region") as IEnumerable <Region>).Where(x => x.RegionID == cmd.Id).Single(); AdminService service = new AdminService(_context, _userManager, _getterUtils); service.UpdateRegion(new Region { Nombre = cmd.Nombre }, region); return(RedirectToAction("EditRegion")); } return(View(cmd)); }
public async Task <IActionResult> PendingUsers() { GetterAll getter = new GetterAll(_getterUtils, _context, _signInManager, _userManager); List <Usuario> pending = new List <Usuario>(); foreach (var item in getter.GetAll("Usuario")) { if ((await _userManager.GetClaimsAsync(item as Usuario)).Any(c => c.Type == "Pending" && c.Value == "true")) { pending.Add(item as Usuario); } } PendingUsersViewModel vm = new PendingUsersViewModel() { Usuarios = pending, }; return(View(vm)); }
public async Task <IActionResult> PendingUsers(PendingUsersViewModel vm) { var user = await _userManager.FindByIdAsync(vm.userID); await _userManager.RemoveClaimAsync(user, new Claim("Pending", "true")); await _userManager.AddClaimAsync(user, new Claim("Pending", "false")); _context.Commit(); GetterAll getter = new GetterAll(_getterUtils, _context, _signInManager, _userManager); List <Usuario> pending = new List <Usuario>(); foreach (var item in getter.GetAll("Usuario")) { if ((await _userManager.GetClaimsAsync(item as Usuario)).Any(c => c.Type == "Pending" && c.Value == "true")) { pending.Add(item as Usuario); } } return(RedirectToAction("PendingUsers", "Admin")); }
public IActionResult UpdateVisa(EditVisaViewModel vm) { AdminService service = new AdminService(_context, _userManager, _getterUtils); var getter = new GetterAll(_getterUtils, _context); var visas = (IEnumerable <Visa>)getter.GetAll("Visa"); Visa toUpd = visas.Where(v => v.VisaID == vm.id).Single(); Visa entity = new Visa() { Name = vm.Nombre }; if (vm.SelectedRegion != null && vm.SelectedRegion.Count() > 0) { var regiones = (IEnumerable <Region>)getter.GetAll("Region"); var regiones_visas = (IEnumerable <Region_Visa>)getter.GetAll("Region_Visa"); List <Region_Visa> regiones_visa = new List <Region_Visa>(); foreach (var name in vm.SelectedRegion) { foreach (var region in regiones) { if (region.Nombre == name) { var old = regiones_visas.Where(rv => rv.Region.Nombre == name && rv.Visa.Name == toUpd.Name).SingleOrDefault(); if (old != null) { regiones_visa.Add(old); } else { regiones_visa.Add(new Region_Visa() { Region = region, Visa = toUpd }); } break; } } } toUpd.Regiones = regiones_visa; } if (vm.SelectedPais != null && vm.SelectedPais.Count() > 0) { var paises = (IEnumerable <Pais>)getter.GetAll("Pais"); var paises_visas = (IEnumerable <Pais_Visa>)getter.GetAll("Pais_Visa"); List <Pais_Visa> paises_visa = new List <Pais_Visa>(); foreach (var name in vm.SelectedPais) { foreach (var pais in paises) { if (pais.Nombre == name) { var old = paises_visas.Where(pv => pv.Pais.Nombre == name && pv.Visa.Name == toUpd.Name).SingleOrDefault(); if (old != null) { paises_visa.Add(old); } else { paises_visa.Add(new Pais_Visa() { Pais = pais, Visa = toUpd }); } break; } } } toUpd.Paises = paises_visa; } service.UpdateVisa(entity, toUpd); return(RedirectToAction("EditVisa")); }
public IActionResult EditUsuario() { GetterAll getter = new GetterAll(_getterUtils, _context, _signInManager, _userManager); return(View(getter.GetAll("Usuario"))); }
public IActionResult EditPais() { var getter = new GetterAll(_getterUtils, _context); return(View(getter.GetAll("Pais"))); }