public ActionResult DeleteCpsp(CpspDtoModel cpspToDelete) { var originalCpspToDelete = _entities.CPSP.First(m => m.Id == cpspToDelete.Id); _entities.DeleteObject(originalCpspToDelete); _entities.SaveChanges(); return(RedirectToAction("GetAllCPSP")); }
public ActionResult EditCpsp(CpspDtoModel cpsPtoEdit) { try { _cpspDataProvider.EditCPSP(cpsPtoEdit); return(RedirectToAction("GetAllCPSP")); } catch { return(RedirectToAction("GetAllCPSP")); } }
public ActionResult CreateCPSP(CpspDtoModel cpsPtoCreate) { try { _cpspDataProvider.CreateCPSP(cpsPtoCreate); return(RedirectToAction("CreateTelefono")); } catch { return(RedirectToAction("GetAllCPSP")); } }
public ActionResult EditCpsp(int id) { var cpspToEdit = _entities.CPSP.Single(c => c.Id == id); var cpspDtoToEdit = new CpspDtoModel { Id = cpspToEdit.Id, Nombre = cpspToEdit.Nombre, ProvinciaId = cpspToEdit.IdProvincia, CantonId = cpspToEdit.IdCanton, DistritoId = cpspToEdit.IdDistrito, Provincias = _geographicInfoDataProvider.GetAllProvinces(), Cantones = _geographicInfoDataProvider.GetAllCantones(null), Distritos = _geographicInfoDataProvider.GetAllDistrites(null) }; return(View(cpspDtoToEdit)); }
public string CreateCPSP(CpspDtoModel cpspModel) { try { var cpsp = new CPSPx(); cpsp.Nombre = cpspModel.Nombre; cpsp.IdProvincia = cpspModel.ProvinciaId; cpsp.IdCanton = cpspModel.CantonId; cpsp.IdDistrito = cpspModel.DistritoId; _commonDataRepository.CreateCpsp(cpsp); return("Creada exitosamente"); } catch (Exception e) { return(string.Format("Error al crear la encuesta. Detalles: {0}", e.Message)); } }
public string EditCPSP(CpspDtoModel cpspToEdit) { try { var cpsp = new CPSPx { Id = cpspToEdit.Id, Nombre = cpspToEdit.Nombre, IdProvincia = cpspToEdit.ProvinciaId, IdCanton = cpspToEdit.CantonId, IdDistrito = cpspToEdit.DistritoId }; _commonDataRepository.SaveCpsp(cpsp); return("Creado exitosamente"); } catch (Exception e) { return(string.Format("Error al crear el CPSP. Detalles: {0}", e.Message)); } }
//BORRAR public ActionResult DeleteCpsp(int id) { var cpsp = _entities.CPSP.Single(c => c.Id == id); var prov = _entities.Provincia.Single(c => c.Id == cpsp.IdProvincia); var canton = _entities.Canton.Single(c => c.Id == cpsp.IdCanton); var dist = _entities.Distrito.Single(c => c.Id == cpsp.IdDistrito); var cpspDtoToEdit = new CpspDtoModel { Id = cpsp.Id, Nombre = cpsp.Nombre, ProvinciaId = cpsp.IdProvincia, CantonId = cpsp.IdCanton, DistritoId = cpsp.IdDistrito, Provincia = _geographicInfoDataProvider.GetLocationInfoObject(prov.Id, prov.Nombre, null), Canton = _geographicInfoDataProvider.GetLocationInfoObject(canton.Id, canton.Nombre, canton.IdProvincia), Distrito = _geographicInfoDataProvider.GetLocationInfoObject(dist.Id, dist.Nombre, dist.IdCanton) }; return(View(cpspDtoToEdit)); }